This topic provides an example of simplified deployment for you to experience the physical backup and restore feature of OceanBase Database. The deployment solution involves the following three steps:
- Initiate log archiving.
- Initiate data backup.
- Initiate physical restore.
Considerations
- This topic takes the backup of a single tenant as an example. To back up multiple tenants, you need to configure a separate path for the backup destination and archive destination for each tenant. Different tenants cannot share the same path.
- OceanBase Database supports data restore both within a cluster and across clusters.
Prerequisites
This example uses Network File System (NFS) as the backup medium. Before you perform physical backup and restore, make sure that NFS has been deployed. For more information about how to deploy NFS, see Deploy NFS.
Background information
This topic takes the non-encrypted tenant oracle_test as an example to describe how to restore the backup data of the tenant to a new tenant named oracle_backup.
The key information for this example is as follows:
The log archive path of the source tenant is
/data/nfs/backup/archive.The default business prioritizing mode (Optional) is used for archiving, and a log Piece is switched every day.
The data backup path of the source tenant is
/data/nfs/backup/data.The resource pool of the target tenant
oracle_backupto be restored isrestore_pool, the replicaLocalityisF@z1, and the tenant is restored to the latest point.If the cluster where the tenant resides is a multi-replica cluster, see Restore data for step-by-step restore instructions.
Procedure
Step 1: Initiate log archiving
Log in to the database as the tenant administrator of the
oracle_testtenant.Execute the following command to configure the archive destination.
obclient> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=file:///data/nfs/backup/archive';Enable the log archiving mode.
obclient> ALTER SYSTEM ARCHIVELOG;Confirm that 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: file:///data/nfs/backup/archive 1 row in setFrom the query result, the log archiving status
STATUSisDOING.
For more information about log archiving operations and instructions, see Log archiving.
Step 2: Initiate data backup
After confirming that the log archiving status is DOING, you can initiate data backup.
Log in to the database as the tenant administrator of the
oracle_testtenant.Execute the following command to configure the backup destination.
obclient> ALTER SYSTEM SET DATA_BACKUP_DEST='file:///data/nfs/backup/data';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: file:///data/nfs/backup/data 1 row in set
For more information about data backup operations and instructions, see Data backup.
Step 3: Execute 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 the resource pool used by the target tenant. We recommend that you keep the same structure as the source tenant, that is, use the same
UNIT_NUMvalue as the source tenant.obclient> CREATE RESOURCE POOL restore_pool UNIT = 'unit_backup', UNIT_NUM = 1, ZONE_LIST = ('z1');
Execute physical restore to restore the new tenant
oracle_backup.obclient> ALTER SYSTEM RESTORE oracle_backup FROM 'file:///data/nfs/backup/data,file:///data/nfs/backup/archive' WITH 'pool_list=restore_pool&locality=F@z1';
For more information about physical restore operations and instructions, see Restore data.