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
Log on to the database as an administrator of the
systenant or a user tenant.Note
The administrator user is
rootin MySQL mode andSYSin Oracle mode.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_destcannot be a string with a question mark (?). data_backup_destmust 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';- The value of
Alibaba Cloud OSS
When you use OSS as the backup destination, you can set the backup destination and the
delete_modeparameter to configure the backup file clearing mode.The
delete_modecan be set to either of the following modes:deletespecifies 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 modedeleteis used.taggingspecifies 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_modeand the value is set totagging. 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
deleteortaggingmode, 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';
Query for the backup paths of all tenants in the current cluster from the
CDB_OB_BACKUP_PARAMETERview in thesystenant.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
formatfile does not exist, the directory where the configured destination is located must be empty so that theLOG_ARCHIVE_DESTparameter can be set. If this directory is not empty, the system returns the-9081error to indicate that theformatfile does not exist.If the
formatfile exists, its content must be verified so that the parameter can be set. Otherwise, the system returns the-9081error to indicate that theformatfile does not match. The content of theformatfile 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
formatfile does not exist or fails the verification.