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 and ensure that the path is an empty directory. 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.
Here is the key information:
The log archive path of the source tenant is
/data/nfs/backup/archive.The default business prioritizing mode (optional) is required for archiving, and a log piece needs to be generated every two days.
The data backup path of the source tenant is
/data/nfs/backup/data.The resource pool of the restore destination tenant
oracle_backupisrestore_pool. TheLocalityreplica isF@z1. The tenant data needs to be restored to the latest timestamp.For more information about how to restore a tenant in a multi-replica cluster, see Restore data.
Procedure
Step 1: Initiate log archiving
Log in to the database as the administrator of the
oracle_testtenant.Configure the archive destination.
obclient> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=file:///data/nfs/backup/archive';Enable log archiving.
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: file:///data/nfs/backup/archive 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 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
oracle_testtenant.Configure the backup destination.
obclient> ALTER SYSTEM SET DATA_BACKUP_DEST='file:///data/nfs/backup/data';Initiate a full data backup job.
obclient> ALTER SYSTEM BACKUP DATABASE;Wait for the data backup to be completed.
You can query the
DBA_OB_BACKUP_TASKSview to check whether the data backup job is completed. If the returned job list is empty, the data backup job is completed.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: Perform physical restore
Log in as the
rootuser to thesystenant of the cluster where the destination tenant resides.Create the resources required for the destination 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 destination tenant. We recommend that you create a resource pool with the same specifications as the source tenant if possible, that is, using the same
UNIT_NUMvalue as the source tenant.obclient> CREATE RESOURCE POOL restore_pool UNIT = 'unit_backup', UNIT_NUM = 1, ZONE_LIST = ('z1');
Initiate a physical restore job to restore data to the
oracle_backuptenant.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 the operations and instructions on physical restore, see Restore data.