This topic provides a minimal tenant-level backup and restore example as a complete minimal usage guide for first-time users of the physical backup and restore feature of OceanBase AI Database. It mainly involves the following three steps:
- Initiate log archiving.
- Initiate data backup.
- Initiate physical restore.
Considerations
- This topic uses the backup of a single tenant as an example. To back up multiple tenants, you must configure an independent empty directory for the backup path and archive path of each tenant. Different tenants cannot use the same path.
- OceanBase AI Database supports restore both within a cluster and across clusters.
Background information
This topic uses the non-encrypted tenant user_test as an example to describe how to back up the tenant by using the physical backup feature and then restore a new tenant named user_backup from the backup data.
The key information in this example is as follows:
The log archive path of the source tenant is
/data/backup/archive.The archive mode is set to the default business priority mode (Optional), and a log piece is switched every other day.
The data backup path of the source tenant is
/data/backup/data.For the target tenant
user_backupto be restored, the resource pool isrestore_pool, theLocalityreplica isF@z1, and the tenant is restored to the latest timestamp.If the cluster where the tenant resides is a multi-replica cluster, see Preparations before restore to perform the restore step by step.
Procedure
Step 1: Initiate log archiving
Log in to the database as the administrator of the
user_testtenant.Run the following command to configure the archive destination.
obclient> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=s3:///data/backup/archive?host=obs.****.myhuaweicloud.com&access_id=****&access_key=****';Enable the log archiving mode.
obclient> ALTER SYSTEM ARCHIVELOG;Check whether the log archiving status is
DOING. You can initiate data backup only when the log archiving status isDOING.obclient> SELECT * FROM DBA_OB_ARCHIVELOG\GThe query result is as follows:
*************************** 1. row *************************** DEST_ID: 1001 ROUND_ID: 1 INCARNATION: 1 DEST_NO: 0 STATUS: DOING START_SCN: 1706670992366131000 START_SCN_DISPLAY: 2024-01-31 11:16:32.366131 CHECKPOINT_SCN: 1706670992366131001 CHECKPOINT_SCN_DISPLAY: 2024-01-31 11:16:32.366131 COMPATIBLE: 1 BASE_PIECE_ID: 1 USED_PIECE_ID: 1 PIECE_SWITCH_INTERVAL: 86400000000 UNIT_SIZE: 1 COMPRESSION: none INPUT_BYTES: 54533925 INPUT_BYTES_DISPLAY: 52.01MB OUTPUT_BYTES: 54533925 OUTPUT_BYTES_DISPLAY: 52.01MB COMPRESSION_RATIO: 1.00 DELETED_INPUT_BYTES: 0 DELETED_INPUT_BYTES_DISPLAY: 0.00MB DELETED_OUTPUT_BYTES: 0 DELETED_OUTPUT_BYTES_DISPLAY: 0.00MB COMMENT: PATH: s3://data/backup/archive?host=obs.****.myhuaweicloud.com 1 row in setThe query result shows that the value of the log archiving status field
STATUSisDOING.
For more information about log archiving operations and instructions, see Overview of log archiving.
Step 2: Initiate data backup
Make sure that the log archiving status is DOING before you initiate data backup.
Log in to the database as the administrator of the
user_testtenant.Run the following command to configure the backup destination.
obclient> ALTER SYSTEM SET DATA_BACKUP_DEST='s3:///data/backup/data?host=obs.****.myhuaweicloud.com&access_id=****&access_key=****';Initiate a full data backup.
obclient> ALTER SYSTEM BACKUP DATABASE;Wait for the data backup to complete.
You can query the
DBA_OB_BACKUP_TASKSview. If the returned task list is empty, the data backup is complete.obclient> SELECT * FROM DBA_OB_BACKUP_TASKS;View the data backup result.
obclient> SELECT * FROM DBA_OB_BACKUP_JOB_HISTORY;The query result is as follows:
*************************** 1. row *************************** JOB_ID: 1 INCARNATION: 1 BACKUP_SET_ID: 1 INITIATOR_TENANT_ID: 1002 INITIATOR_JOB_ID: 0 EXECUTOR_TENANT_ID: 1002 PLUS_ARCHIVELOG: OFF BACKUP_TYPE: FULL JOB_LEVEL: USER_TENANT ENCRYPTION_MODE: NONE PASSWD: START_TIMESTAMP: 2024-01-31 11:20:59.804836 END_TIMESTAMP: 2024-01-31 11:23:08.773566 STATUS: COMPLETED RESULT: 0 COMMENT: DESCRIPTION: PATH: s3://data/backup/data?host=obs.****.myhuaweicloud.com 1 row in set
For more information about data backup operations and instructions, see Prepare for backup.
Step 3: Perform physical restore
Log in as the
rootuser to thesystenant of the cluster where the target tenant resides.Create the resources required for the target tenant.
Create a resource unit named
unit_backup.obclient> CREATE RESOURCE UNIT unit_backup MAX_CPU 8, MEMORY_SIZE = '16G', MAX_IOPS 10240, MIN_IOPS=10240;Create a resource pool for the target tenant. We recommend that you create a resource pool with the same specifications as the source tenant, that is, the number of
UNIT_NUMin the resource pool is the same as that in the source tenant.obclient> CREATE RESOURCE POOL restore_pool UNIT = 'unit_backup', UNIT_NUM = 1, ZONE_LIST = ('z1');
Initiate a physical restore task to restore data to the
user_backuptenant.obclient> ALTER SYSTEM RESTORE user_backup FROM 's3://data/backup/data?host=obs.****.myhuaweicloud.com,s3:///data/backup/archive?host=obs.****.myhuaweicloud.com' WITH 'pool_list=restore_pool&locality=F@z1';
For more information about the operations and instructions on physical restore, see Preparations before restore.