Before performing a data backup, you must complete some preparatory tasks, including configuring the backup destination and backing up the tenant key.
Configure the backup destination
When configuring the backup destination, note that the sys tenant does not contain user data. It is a tenant used for cluster management, and backup and restore are not supported for the sys tenant. Therefore, you do not need to configure the DATA_BACKUP_DEST parameter for the sys tenant.
Considerations
When configuring the backup destination, you must set the backup path of each tenant to an independent empty directory. Different tenants cannot use the same backup path.
Procedure
Log in to the database as the tenant administrator of the
systenant or a user tenant.Note
The administrator user of a user tenant is the
rootuser.Configure the backup destination.
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 a user tenant.
The statement is as follows:
ALTER SYSTEM SET DATA_BACKUP_DEST= 'data_backup_path';
Currently, OceanBase AI Database supports the following backup media: Azure Blob, AWS S3, and object storage services compatible with the S3 protocol, such as Alibaba Cloud OSS, Huawei OBS, Google GCS, and Tencent Cloud COS. Some backup media may require meeting specific basic requirements before use. For the specific requirements of each backup medium, see Backup media requirements in Overview of physical backup and restore.
Detailed settings are described below.
AWS S3Object storage compatible with the S3 protocolAzure BlobAWS S3 supports configuring the cleanup mode for backup files by using the
delete_modeparameter. AWS S3 also supports specifying a checksum algorithm for verifying the integrity of backup data by using thechecksum_typeparameter. The supported values aremd5andcrc32. If thechecksum_typeparameter is not explicitly configured, the default value ismd5.For more information about the
delete_modeandchecksum_typeparameters, see SET DATA_BACKUP_DEST.Notice
When you use an object storage service as the backup medium, the parameters of the object storage path are separated by
&. Make sure that the parameter values contain only uppercase and lowercase English letters, numbers,/-_$+=, and wildcard characters. If you enter other characters, the configuration may fail.The following examples show how to configure AWS S3 as the backup medium:
When using AWS S3 as the backup medium, set the backup path for the
mysql_tenanttenant in the sys tenant, configure the cleanup mode todelete, and specify the checksum algorithm ascrc32.obclient> ALTER SYSTEM SET DATA_BACKUP_DEST='s3://oceanbase-test-bucket/backup/data?host=s3.<region>.amazonaws.com&access_id=****&access_key=****&s3_region=****&delete_mode=delete&checksum_type=crc32' TENANT = mysql_tenant;When using AWS S3 as the backup medium, set the backup path for the current tenant, configure the cleanup mode to
delete, and specify the checksum algorithm ascrc32.obclient> ALTER SYSTEM SET DATA_BACKUP_DEST='s3://oceanbase-test-bucket/backup/data?host=s3.<region>.amazonaws.com&access_id=****&access_key=****&s3_region=****&delete_mode=delete&checksum_type=crc32';
In the examples,
s3://indicates using AWS S3 as the backup medium type, the bucket name isoceanbase-test-bucket, and the path in the bucket is/backup/data. The?character is used to separate the path from the parameters, and&separates the parameters.hostis used to set the domain name for the Amazon S3 service,access_idandaccess_keyare used to set the access keys for the AWS service, ands3_regionis a required parameter when using AWS S3 as the backup medium, indicating the region where the S3 bucket is located. The cleanup mode isdelete, and the CRC32 algorithm is used to verify the integrity of backup data.For more information about the AWS S3 path format, see Appendix: S3 path format.
Because most object storage services are compatible with the S3 protocol, any object storage service that is compatible with S3 and meets the requirements of OceanBase AI Database (the object storage must be compatible with the behavior of several S3 APIs that implement OceanBase system calls) can be used as a backup medium for OceanBase AI Database. Access to compatible object storage services, such as OBS, GCS, and COS, is provided through S3.
For object storage services such as OBS, GCS, and COS accessed through the S3 protocol, you can also specify a checksum algorithm for verifying the integrity of backup data by using the
checksum_typeparameter. The only supported value ismd5. If thechecksum_typeparameter is not explicitly configured, its default value ismd5. For more information about thechecksum_typeparameter, see SET DATA_BACKUP_DEST.Notice
- When you use an object storage service as the backup medium, the parameters of the object storage path are separated by
&. Make sure that the parameter values contain only uppercase and lowercase English letters, numbers,/-_$+=, and wildcard characters. If you enter other characters, the configuration may fail. - Some object storage services compatible with the S3 protocol may not support the default URL encoding method of the AWS S3 SDK. When you access them by using the
s3://protocol, if object storage-related error codes such as 9129 or 9026 occur, we recommend that you set the cluster-level configuration item ob_storage_s3_url_encode_type to specify that AWS S3 uses an RFC 3986-compliant URL encoding method when sending requests. For more information, see the Procedure and example: Use COS as the backup medium section below.
The following example shows how to configure OBS as the backup medium:
When using OBS as the backup medium, set the backup path for the
mysql_tenanttenant in the sys tenant.obclient> ALTER SYSTEM SET DATA_BACKUP_DEST='s3://oceanbase-test-bucket/backup/data?host=obs.****.myhuaweicloud.com&access_id=****&access_key=****' TENANT = mysql_tenant;When using OBS as the backup medium, set the backup path for the current tenant.
obclient> ALTER SYSTEM SET DATA_BACKUP_DEST='s3://oceanbase-test-bucket/backup/data?host=obs.****.myhuaweicloud.com&access_id=****&access_key=****';
In the preceding examples,
s3://indicates that the backup destination is accessed through the S3 protocol. The bucket name isoceanbase-test-bucket, and the path in the bucket is/backup/data. The?symbol separates the path from the parameters, and the parameters are separated by&.hostspecifies the domain name of the OBS service, andaccess_idandaccess_keyspecify the access keys of the OBS service.The following example shows how to configure GCS as the backup medium:
When using GCS as the backup medium, set the backup path for the
mysql_tenanttenant in the sys tenant.obclient> ALTER SYSTEM SET DATA_BACKUP_DEST='s3://oceanbase-test-bucket/backup/data?host=https://storage.googleapis.com&access_id=****&access_key=****' TENANT = mysql_tenant;When using GCS as the backup medium, set the backup path for the current tenant.
obclient> ALTER SYSTEM SET DATA_BACKUP_DEST='s3://oceanbase-test-bucket/backup/data?host=https://storage.googleapis.com&access_id=****&access_key=****';
In the preceding examples,
s3://indicates that the backup destination is accessed through the S3 protocol. The bucket name isoceanbase-test-bucket, and the path in the bucket is/backup/data. The?symbol separates the path from the parameters, and the parameters are separated by&.hostspecifies the domain name of the GCS service, andaccess_idandaccess_keyspecify the access keys of the GCS service.The procedure and example for using COS as the backup medium are as follows:
View the value of the cluster-level configuration item
ob_storage_s3_url_encode_type.obclient> SHOW PARAMETERS LIKE '%ob_storage_s3_url_encode_type%';The query result is as follows:
+-------+----------+----------------+----------+-------------------------------+-----------+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+ | zone | svr_type | svr_ip | svr_port | name | data_type | value | info | section | scope | source | edit_level | +-------+----------+----------------+----------+-------------------------------+-----------+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+ | zone1 | observer | 172.xx.xxx.xxx | 2882 | ob_storage_s3_url_encode_type | NULL | default | Determines the URL encoding method for S3 requests."default": Uses the S3 standard URL encoding method."compliantRfc3986Encoding": Uses URL encoding that adheres to the RFC 3986 standard. | OBSERVER | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE | +-------+----------+----------------+----------+-------------------------------+-----------+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+ 1 row in setIf the value is
default, change it tocompliantRfc3986Encoding.obclient>ALTER SYSTEM SET ob_storage_s3_url_encode_type='compliantRfc3986Encoding';For more information about this configuration item, see ob_storage_s3_url_encode_type.
Set the backup path and specify the mode for deleting backup files by using the
delete_modeparameter.Use COS as the backup medium. Set the backup path for the
mysql_tenanttenant in the sys tenant and configure thedeletemode for deleting backup files:obclient> ALTER SYSTEM SET DATA_BACKUP_DEST='s3://oceanbase-test/backup/data?host=cos.ap-xxxx.myqcloud.com&access_id=***&access_key=***&delete_mode=delete' TENANT = mysql_tenant;Use COS as the backup medium. Set the backup path for the current tenant and configure the
deletemode for deleting backup files:obclient> ALTER SYSTEM SET DATA_BACKUP_DEST='s3://oceanbase-test/backup/data?host=cos.ap-xxxx.myqcloud.com&access_id=***&access_key=***&delete_mode=delete';In the examples,
s3://indicates that the backup destination is accessed through the S3 protocol. The bucket name isoceanbase-test, and the path in the bucket is/backup/archive. The?character is used to separate the path from the parameters, and the&character is used to separate the parameters.hostspecifies the COS host address, which is the endpoint (the address without the bucket name).access_idandaccess_keyare used to set the access keys forCOS, and the cleanup mode is set todelete.
Azure Blob also supports the
delete_modeandchecksum_typeparameters. Thedelete_modeparameter specifies the cleanup mode for the backup files. If you do not explicitly configure thedelete_modeparameter, thedeletemode is used by default. Thechecksum_typeparameter specifies the checksum algorithm for verifying the integrity of the backup files. The supported values aremd5andno_checksum. If you do not explicitly configure thechecksum_typeparameter, the default value ismd5.For more information about these parameters, see SET DATA_BACKUP_DEST.
Here are some examples:
Notice
- When you use object storage as the backup medium, the parameters in the object storage path are separated by the
&symbol. Make sure that the parameter values you enter contain only uppercase and lowercase letters, numbers,/-_$+=, and wildcards. Entering characters other than those listed above may cause the configuration to fail. - When you use Azure Blob as the backup medium, the prefix of the
hostparameter must be specified ashttp://orhttps://. In addition, secure transmission is enabled by default for Azure Blob, so access is usually performed throughhttps://. If you need to access Azure Blob throughhttp://, you must disable the secure transmission option for Azure Blob. For more information about how to disable the secure transmission option, see the Azure Blob official documentation.
When you use Azure Blob as the backup medium, set the backup path for the
mysql_tenanttenant in the system tenant. The cleanup mode isdelete, and the checksum algorithm ismd5.obclient> ALTER SYSTEM SET DATA_BACKUP_DEST='azblob://oceanbase-test-bucket/backup/data?host=http://****.blob.core.windows.net&access_id=****&access_key=****&delete_mode=delete&checksum_type=md5' TENANT = mysql_tenant;When you use Azure Blob as the backup medium, set the backup path for the current tenant in the user tenant. The cleanup mode is
delete, and the checksum algorithm ismd5.obclient> ALTER SYSTEM SET DATA_BACKUP_DEST='azblob://oceanbase-test-bucket/backup/data?host=http://****.blob.core.windows.net&access_id=****&access_key=****&delete_mode=delete&checksum_type=md5';
In the preceding examples,
azblob://indicates that Azure Blob is used as the backup medium. The bucket name isoceanbase-test-bucket, and the path in the bucket is/backup/data. The?character is used to separate the path from the parameters, and the&character is used to separate the parameters.hostspecifies the host address of the bucket, which can be obtained by concatenating the container properties or the connection string of the storage account.access_idis the name of the storage account, andaccess_keyis the access key for Azure Blob. The cleanup mode isdelete, and the MD5 algorithm is used to verify the integrity of the backup files.After the configuration is completed, you can view the detailed configuration information in views.
The
systenant can query theCDB_OB_BACKUP_PARAMETERview, and a user tenant can query theDBA_OB_BACKUP_PARAMETERview.For more information about data backup-related parameters and how to view them, see View data backup parameters.
Considerations and descriptions after the configuration is completed
After the
data_backup_destparameter is successfully configured, the system creates aformatfile in the directory where the specified backup destination is located by default. Theformatfile is used to verify the validity of the backup destination and ensure the integrity of data in the destination. Therefore, note the following considerations when you configure the backup destination:If the
formatfile does not exist, the specified directory must be empty. Otherwise, an error-9080is returned, indicating that the file does not exist.If the
formatfile already exists, its content must pass the verification for the specified parameter to take effect. Otherwise, an error-9081is returned, indicating that the file does not match. The content verification of theformatfile mainly checks whether the cluster, tenant, and backup destination type specified in the file are consistent with those in the current operation.If the
formatfile does not exist or its content fails the verification during backup task execution, the task will fail.
After the backup destination is set successfully, if you change the key information of the object storage due to security or other reasons, you need to update the
access_idandaccess_keyinformation for the configured backup paths. For more information, see Update object storage key information.
Back up the tenant key
Before you back up data, you also need to consider the encryption status of the source tenant. If transparent data encryption is configured for the source tenant, you must back up its key.
Notice
After backing up the key, if a key rotation is triggered for the source tenant's encryption information before data restoration, you need to back up the source tenant's key again.
Log in to the database as the tenant administrator of the
systenant or a user tenant.Back up the key.
The system tenant backs up the key for a specified tenant
ALTER SYSTEM BACKUP KEY TENANT = tenant_name TO 'backup_key_path' ENCRYPTED BY 'password';A user tenant backs up the key for itself
The statement is as follows:
ALTER SYSTEM BACKUP KEY TO 'backup_key_path' ENCRYPTED BY 'password';
In the statement:
backup_key_path: Specifies the path for backing up the key. This path is user-defined and must not be the same as the path used for data backup or log archiving.password: Specifies an encryption password for the key backup path.
The following example shows the system tenant backing up the key for tenant
mysql_tenantto the pathfile:///data_backup_dest/key:obclient [(none)]> ALTER SYSTEM BACKUP KEY TENANT = mysql_tenant TO 'file:///data_backup_dest/key' ENCRYPTED BY '******';After the configuration is completed, you can view the key backup path in a view.
The system tenant views the key backup path in the
CDB_OB_BACKUP_STORAGE_INFOviewSELECT * FROM oceanbase.CDB_OB_BACKUP_STORAGE_INFO;A user tenant views the key backup path in the
DBA_OB_BACKUP_STORAGE_INFOviewThe statement is as follows:
SELECT * FROM oceanbase.DBA_OB_BACKUP_STORAGE_INFO;For more information about the columns in the
CDB_OB_BACKUP_STORAGE_INFOandDBA_OB_BACKUP_STORAGE_INFOviews, see CDB_OB_BACKUP_STORAGE_INFO and DBA_OB_BACKUP_STORAGE_INFO.