Preparations

2023-08-01 06:02:28  Updated

You must configure the DATA_BACKUP_DEST parameter before the backup. The sys tenant is used for managing clusters and does not contain user data or support backup and restore. Therefore, you do not need to configure the DATA_BACKUP_DEST parameter for the sys tenant.

Configure the backup destination

  1. Log on to the database as an administrator of the sys tenant or a user tenant.

    Note

    The administrator user is root in MySQL mode and SYS in Oracle mode.

  2. Configure the backup destination.

    OceanBase Database supports two types of media as the backup destination: Network File System (NFS) and Alibaba Cloud Object Storage Service (OSS).

    • Configure the backup destination for a specified tenant in the sys tenant

      ALTER SYSTEM SET DATA_BACKUP_DEST = 'data_backup_path' TENANT = mysql_tenant;
      
    • Configure the backup destination for the current tenant in a user tenant

      Sample statement:

      ALTER SYSTEM SET DATA_BACKUP_DEST = 'data_backup_path';
      

    Notice

    For scenarios where users upgrade from OceanBase Database V4.0.x to V4.1.0, the backup path should be changed after the upgrade.

    Examples:

    • NFS

      Notice

      When you use NFS as the backup destination, note the following points:

      • The value of data_backup_dest cannot be a string with a question mark (?).
      • data_backup_dest must be set to an absolute path to ensure that the OBServer node has the write privilege on the backup destination.
      • Ensure that all OBServer nodes are mounted to NFS of the same server and use the parameter settings recommended in this topic. For more information about the procedure of mounting NFS, see Deploy the NFS client.

      Set the backup destination to NFS:

      obclient [(none)]> ALTER SYSTEM SET DATA_BACKUP_DEST = 'file:///data/nfs/backup/data' TENANT = mysql_tenant;
      
      obclient [(none)]> ALTER SYSTEM SET DATA_BACKUP_DEST = 'file:///data/nfs/backup/data';
      
    • Alibaba Cloud OSS

      When you use OSS as the backup destination, you can set the backup destination and the delete_mode parameter to configure the backup file clearing mode.

      The delete_mode can be set to either of the following modes:

      • delete specifies that backup files that meet requirements are directly cleared.

        After you configure this mode, the system clears backup files that meet the requirements, regardless of whether the backup file clearing mode is automatic or manual. This is the default clearing mode. If you do not specify delete_mode, the default clearing mode delete is used.

      • tagging specifies that backup files that meet the clearing requirements are tagged and retained.

        After you configure this mode, the system tags backup files that meet the clearing requirements, regardless of whether the backup file clearing mode is automatic or manual. The key of the tag is set to delete_mode and the value is set to tagging. This way, you can manage the lifecycle of these files on OSS based on the specified tag.

      For more information about the automatic cleanup of backup data in delete or tagging mode, see Automatic cleanup of expired backup data.

      To set the backup destination and configure a backup file cleanup mode, execute the following statement:

      obclient [(none)]> ALTER SYSTEM SET DATA_BACKUP_DEST = 'oss://oceanbase-test-bucket/backup/?host=xxx.aliyun-inc.com&access_id=xxx&access_key=xxx&delete_mode=delete' TENANT = mysql_tenant;
      
      obclient [(none)]> ALTER SYSTEM SET DATA_BACKUP_DEST = 'oss://oceanbase-test-bucket/backup/?host=xxx.aliyun-inc.com&access_id=xxx&access_key=xxx&delete_mode=delete';
      
  3. Query for the backup paths of all tenants in the current cluster from the CDB_OB_BACKUP_PARAMETER view in the sys tenant.

    obclient [(none)]> SELECT * FROM oceanbase.CDB_OB_BACKUP_PARAMETER\G
    *************************** 1. row ***************************
    TENANT_ID: 1002
         NAME: data_backup_dest
        VALUE: file:///data/nfs/backup/data
    

Considerations

After you set the data_backup_dest parameter, the system will create a file named format by default in the directory where the configured destination is located. This file is used to verify the validity of the backup destination and ensure the integrity of the data at the destination. Therefore, pay attention to the following points when you configure the data_backup_dest parameter:

  • If the format file does not exist, the directory where the configured destination is located must be empty so that the LOG_ARCHIVE_DEST parameter can be set. If this directory is not empty, the system returns the -9081 error to indicate that the format file does not exist.

  • If the format file exists, its content must be verified so that the parameter can be set. Otherwise, the system returns the -9081 error to indicate that the format file does not match. The content of the format file is verified to check whether the types of the cluster, tenant, and backup destination in the file match those of the current cluster, tenant, and backup destination.

  • When you execute a backup job, the job fails to be initiated if the format file does not exist or fails the verification.

Contact Us