This topic describes how to use obd to create a standby tenant in three scenarios.
Applicability
obd can be used to create a standby tenant only for a MySQL tenant.
Concepts
A physical standby database is an important component of the high availability solution of OceanBase Database. It provides high availability, data protection, and disaster recovery capabilities for your critical applications.
A physical standby database serves as a near-real-time hot backup of the production database of OceanBase Database. When the primary database is unavailable due to scheduled or unscheduled (majority replica failure) reasons, the standby database can take over the service to minimize downtime and reduce potential data loss.
Prerequisites
The primary and standby tenants are created in the same cluster. The version of OceanBase Database is V4.2.0 or later.
The primary tenant is a user tenant with complete logs.
Execute the
SELECT LS_ID, BEGIN_LSN FROM oceanbase.GV$OB_LOG_STAT WHERE ROLE = 'LEADER' ;command to check the log status. If theBEGIN_LSNvalue is0, it indicates that the current log stream replica has complete logs since its creation.The primary and standby tenants are in the running state.
Execute the
obd cluster displaycommand to check the cluster status.For a simple experience, the primary tenant requires at least 1C2GB memory and 4GB log disk space. For long-term use, it is recommended to allocate 1C4GB memory or more.
The primary and standby tenants must be managed by the same obd. If not, follow the steps in Take over a cluster using obd to take over the cluster.
Procedure
This section describes the operation of creating a standby tenant based on the network in three scenarios:
Scenario 1: One primary and one standby
In this scenario, two clusters, clusterA and clusterB, are deployed. A primary tenant A_a is created in clusterA, and a standby tenant B_a is created in clusterB.
Scenario 2: One primary and two standbys
In this scenario, three clusters, clusterA, clusterB, and clusterC, are deployed. A primary tenant A_a is created in clusterA, and two standby tenants, B_a and C_a, are created in clusterB and clusterC respectively.
Scenario 3: Cascading primary and standby
In this scenario, three clusters, clusterA, clusterB, and clusterC, are deployed. A primary tenant A_a is created in clusterA, a standby tenant B_a is created in clusterB, and a standby tenant C_a is created in clusterC.
Scenario 1: One primary and one standbyScenario 2: One primary and two standbysScenario 3: Cascading primary and standbyExecute the following command to create a standby tenant B_a for the primary tenant A_a.
obd cluster tenant create-standby clusterB clusterA A_a -t B_a --tenant-root-password=*****Execute the following command to view the primary-standby relationship of the standby tenant.
obd cluster tenant show clusterB -t B_a -gThe
-gparameter displays the primary-standby relationships of clusters. The output is as follows:+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | tenant basic info | +-------------+-------------+--------------------+--------------+---------+---------+-------------+---------------------+---------------------+---------------+-------------+-------------+ | tenant_name | tenant_type | compatibility_mode | primary_zone | max_cpu | min_cpu | memory_size | max_iops | min_iops | log_disk_size | iops_weight | tenant_role | +-------------+-------------+--------------------+--------------+---------+---------+-------------+---------------------+---------------------+---------------+-------------+-------------+ | B_a | USER | MYSQL | RANDOM | 2.0 | 2.0 | 4G | 10000 | 10000 | 5G | 2 | STANDBY | +-------------+-------------+--------------------+--------------+---------+---------+-------------+---------------------+---------------------+---------------+-------------+-------------+ +-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | standby tenant standby info | +---------------------+---------------+-------------+----------------------------+----------+---------------+-------------------+------------------+--------------+ | standby_tenant_name | tenant_status | sync_status | sync_scn_timestamp | err_code | error_comment | switchover_status | switchover_epoch | log_mode | +---------------------+---------------+-------------+----------------------------+----------+---------------+-------------------+------------------+--------------+ | B_a | NORMAL | NORMAL | 2023-09-14 08:58:44.173462 | 0 | | NORMAL | 0 | NOARCHIVELOG | +---------------------+---------------+-------------+----------------------------+----------+---------------+-------------------+------------------+--------------+ +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | standby tenant`s primary info | +---------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | standby_tenant_name | primary_tenant_info | +---------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | B_a | IP_LIST=10.10.10.1:2881;10.10.10.2:2881;10.10.10.3:2881,USER=standbyro@A_a,PASSWORD=******,TENANT_ID=1002,CLUSTER_ID=1694680744,COMPATIBILITY_MODE=MYSQL,IS_ENCRYPTED=false | +---------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ query primary-standby relation ok primary-standby relation topology graph clusterA:A_a └── clusterB:B_aIf the values of
tenant_statusandsync_statusare bothNORMAL, the standby tenant is created successfully and the log transmission is normal. The following table describes the modules in the output.tenant base info: This table displays the tenant information in the cluster. You need to pay attention to the following items.
Column nameDescriptiontenant_name The name of the tenant. tenant_type The type of the tenant. Valid values: SYSandUSER.compatibility_mode The compatibility mode of the tenant. Valid values: MySQLandOracle. The community edition supports only theMySQLcompatibility mode.primary_zone The primary zone of the tenant. tenant_role The role of the tenant. Valid values: PRIMARY: primary tenantSTANDBY: standby tenantRESTORE: tenant is being restored
standby tenant standby info: This table displays the specific information of the standby tenant in the cluster. You need to pay attention to the following items.
Column nameDescriptionstandby_tenant_name The name of the standby tenant. tenant_status The status of the standby tenant. If the value is NORMAL, the standby tenant is in the normal state.sync_status The log synchronization status of the standby tenant. If the value is NORMAL, the log synchronization status is normal.sync_scn_timestamp The log synchronization point. err_code The error code of the log synchronization. error_comment The error information of the log synchronization. switchover_status The primary-standby tenant switchover status. If the value is NORMAL, the primary-standby tenant switchover status is normal.switchover_epoch The primary-standby tenant switchover time. log_mode The log archiving mode. For primary-standby tenants based on the network, the log archiving mode is NOARCHIVELOG.standby tenant`s primary info: This table displays the information of the primary tenant of the standby tenant in the cluster. You need to pay attention to the following items.
Column nameDescriptionstandby_tenant_name The name of the standby tenant. This parameter is used to identify the primary tenant of the standby tenant. primary_tenant_info The information of the primary tenant of the standby tenant. The information includes the IP address of the node where the primary tenant is located, the name of the primary tenant, the password of the standby user, the ID of the primary tenant, and the ID of the cluster where the primary tenant is located.
Connect to the primary and standby tenants separately, modify the information in the primary tenant (A_a), and check whether the information is synchronized in the standby tenant (B_a).
Execute the following command to create a standby tenant B_a for the primary tenant A_a.
obd cluster tenant create-standby clusterB clusterA A_a -t B_a --tenant-root-password=*****Execute the following command to create a standby tenant C_a for the primary tenant A_a.
obd cluster tenant create-standby clusterC clusterA A_a -t C_a --tenant-root-password=*****Execute the following command to view the primary-standby relationship of the standby tenant. Here, the clusterB cluster is used as an example.
obd cluster tenant show clusterB -t B_a -gThe
-gparameter displays the primary-standby relationships of clusters. The output is as follows:+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | tenant basic info | +-------------+-------------+--------------------+--------------+---------+---------+-------------+---------------------+---------------------+---------------+-------------+-------------+ | tenant_name | tenant_type | compatibility_mode | primary_zone | max_cpu | min_cpu | memory_size | max_iops | min_iops | log_disk_size | iops_weight | tenant_role | +-------------+-------------+--------------------+--------------+---------+---------+-------------+---------------------+---------------------+---------------+-------------+-------------+ | B_a | USER | MYSQL | RANDOM | 2.0 | 2.0 | 4G | 10000 | 10000 | 5G | 2 | STANDBY | +-------------+-------------+--------------------+--------------+---------+---------+-------------+---------------------+---------------------+---------------+-------------+-------------+ +-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | standby tenant standby info | +---------------------+---------------+-------------+----------------------------+----------+---------------+-------------------+------------------+--------------+ | standby_tenant_name | tenant_status | sync_status | sync_scn_timestamp | err_code | error_comment | switchover_status | switchover_epoch | log_mode | +---------------------+---------------+-------------+----------------------------+----------+---------------+-------------------+------------------+--------------+ | B_a | NORMAL | NORMAL | 2023-09-14 09:12:13.819821 | 0 | | NORMAL | 0 | NOARCHIVELOG | +---------------------+---------------+-------------+----------------------------+----------+---------------+-------------------+------------------+--------------+ +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | standby tenant`s primary info | +---------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | standby_tenant_name | primary_tenant_info | +---------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | B_a | IP_LIST=10.10.10.1:2881;10.10.10.2:2881;10.10.10.3:2881,USER=standbyro@A_a,PASSWORD=******,TENANT_ID=1002,CLUSTER_ID=1694680744,COMPATIBILITY_MODE=MYSQL,IS_ENCRYPTED=false | +---------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ query primary-standby relation ok primary-standby relation topology graph clusterA:A_a ├── clusterB:B_a └── clusterC:C_aIf the values of
tenant_statusandsync_statusare bothNORMAL, the standby tenant is created successfully and the log transmission is normal. For more information about the modules in the output, see Scenario 1: One primary and one standby.Connect to the primary and standby tenants separately, modify the information in the primary tenant (A_a), and check whether the information is synchronized in the standby tenants (B_a and C_a).
Execute the following command to create a standby tenant B_a for the primary tenant A_a.
obd cluster tenant create-standby clusterB clusterA A_a -t B_a --tenant-root-password=*****Execute the following command to check whether the standby tenant B_a is created.
obd cluster tenant show clusterB -t B_a -gIf the values of
tenant_statusandsync_statusare bothNORMAL, the standby tenant is created successfully and the log transmission is normal. For more information about the modules in the output, see Scenario 1: One primary and one standby.The
-gparameter displays the primary-standby relationships of clusters. The output is as follows:+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | tenant basic info | +-------------+-------------+--------------------+--------------+---------+---------+-------------+---------------------+---------------------+---------------+-------------+-------------+ | tenant_name | tenant_type | compatibility_mode | primary_zone | max_cpu | min_cpu | memory_size | max_iops | min_iops | log_disk_size | iops_weight | tenant_role | +-------------+-------------+--------------------+--------------+---------+---------+-------------+---------------------+---------------------+---------------+-------------+-------------+ | B_a | USER | MYSQL | RANDOM | 2.0 | 2.0 | 4G | 10000 | 10000 | 5G | 2 | STANDBY | +-------------+-------------+--------------------+--------------+---------+---------+-------------+---------------------+---------------------+---------------+-------------+-------------+ +-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | standby tenant standby info | +---------------------+---------------+-------------+----------------------------+----------+---------------+-------------------+------------------+--------------+ | standby_tenant_name | tenant_status | sync_status | sync_scn_timestamp | err_code | error_comment | switchover_status | switchover_epoch | log_mode | +---------------------+---------------+-------------+----------------------------+----------+---------------+-------------------+------------------+--------------+ | B_a | NORMAL | NORMAL | 2023-09-14 08:58:44.173462 | 0 | | NORMAL | 0 | NOARCHIVELOG | +---------------------+---------------+-------------+----------------------------+----------+---------------+-------------------+------------------+--------------+ +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | standby tenant`s primary info | +---------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | standby_tenant_name | primary_tenant_info | +---------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | B_a | IP_LIST=10.10.10.1:2881;10.10.10.2:2881;10.10.10.3:2881,USER=standbyro@A_a,PASSWORD=******,TENANT_ID=1002,CLUSTER_ID=1694680744,COMPATIBILITY_MODE=MYSQL,IS_ENCRYPTED=false | +---------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ query primary-standby relation ok primary-standby relation topology graph clusterA:A_a └── clusterB:B_aExecute the following command to create a standby tenant C_a for the standby tenant B_a.
Note
It is recommended that you create the standby tenant C_a only after the standby tenant B_a is synchronized.
obd cluster tenant create-standby clusterC clusterB B_a -t C_a --tenant-root-password=*****Execute the following command to view the primary-standby relationship of the standby tenant. Here, the clusterB cluster is used as an example.
obd cluster tenant show clusterB -t B_a -gThe
-gparameter displays the primary-standby relationships of clusters. The output is as follows:+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | tenant basic info | +-------------+-------------+--------------------+--------------+---------+---------+-------------+---------------------+---------------------+---------------+-------------+-------------+ | tenant_name | tenant_type | compatibility_mode | primary_zone | max_cpu | min_cpu | memory_size | max_iops | min_iops | log_disk_size | iops_weight | tenant_role | +-------------+-------------+--------------------+--------------+---------+---------+-------------+---------------------+---------------------+---------------+-------------+-------------+ | B_a | USER | MYSQL | RANDOM | 2.0 | 2.0 | 4G | 10000 | 10000 | 5G | 2 | STANDBY | +-------------+-------------+--------------------+--------------+---------+---------+-------------+---------------------+---------------------+---------------+-------------+-------------+ +-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | standby tenant standby info | +---------------------+---------------+-------------+----------------------------+----------+---------------+-------------------+------------------+--------------+ | standby_tenant_name | tenant_status | sync_status | sync_scn_timestamp | err_code | error_comment | switchover_status | switchover_epoch | log_mode | +---------------------+---------------+-------------+----------------------------+----------+---------------+-------------------+------------------+--------------+ | B_a | NORMAL | NORMAL | 2023-09-14 09:24:48.737141 | 0 | | NORMAL | 0 | NOARCHIVELOG | +---------------------+---------------+-------------+----------------------------+----------+---------------+-------------------+------------------+--------------+ +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | standby tenant`s primary info | +---------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | standby_tenant_name | primary_tenant_info | +---------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | B_a | IP_LIST=10.10.10.1:2881;10.10.10.2:2881;10.10.10.3:2881,USER=standbyro@A_a,PASSWORD=******,TENANT_ID=1002,CLUSTER_ID=1694680744,COMPATIBILITY_MODE=MYSQL,IS_ENCRYPTED=false | +---------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ query primary-standby relation ok primary-standby relation topology graph clusterA:A_a └── clusterB:B_a └── clusterC:C_aConnect to the primary and standby tenants separately, modify the information in the primary tenant (A_a), and check whether the information is synchronized in the standby tenant (B_a) and the standby tenant of the standby tenant (C_a).
Prerequisites
The primary and standby clusters have been created, and the OceanBase Database version is the same and is V4.2.0 or later.
The primary tenant must be a user tenant, and the backup must be completed. For more information about how to back up a tenant, see Tenant backup in Backup and restore.
The primary and standby clusters must be running. You can run the
obd cluster displaycommand to view the cluster status.For a simple experience, the primary tenant must have at least 1C2GB of memory and 4GB of log disk space. For long-term use, the primary tenant must have at least 1C4GB of memory.
The primary and standby clusters must be managed by the same obd. If the cluster is not managed by obd, you can refer to Use obd to takeover a cluster to take over the cluster.
The primary and standby clusters must be able to access shared storage (such as OSS or NFS).
Procedure
This section describes how to create a standby tenant based on an archive in three different scenarios:
Scenario 1: One primary and one standby
In this scenario, two clusters, clusterA and clusterB, are deployed. A primary tenant A_a is created in clusterA, and a standby tenant B_a is created in clusterB.
Scenario 2: One primary and two standbys
In this scenario, three clusters, clusterA, clusterB, and clusterC, are deployed. A primary tenant A_a is created in clusterA, and two standby tenants, B_a and C_a, are created in clusterB and clusterC, respectively.
Scenario 3: Cascading primary and standby
In this scenario, three clusters, clusterA, clusterB, and clusterC, are deployed. A primary tenant A_a is created in clusterA. A standby tenant B_a is created in clusterB, and a standby tenant C_a is created in clusterC.
Notice
In the cascading primary and standby scenario, after you create a standby tenant B_a based on an archive for the primary tenant A_a, you cannot create a standby tenant C_a for the standby tenant B_a based on the network.
Scenario 1: One primary and one standbyScenario 2: One primary and two standbysScenario 3: Cascading primary and standbyRun the following command to create a standby tenant B_a for the primary tenant A_a.
obd cluster tenant create-standby clusterB clusterA A_a --type=LOCATION -t B_a -d 'oss://oceanbase-test-bucket/backup/data?host=****.aliyun-inc.com&access_id=****&access_key=****&delete_mode=delete&checksum_type=md5' -a 'oss://oceanbase-test-bucket/backup/log?host=****.aliyun-inc.com&access_id=****&access_key=****&delete_mode=delete&checksum_type=md5'In this example, OSS is used as the backup medium. You need to replace the backup file path with the actual path.
Run the following command to view the status of the standby tenant.
obd cluster tenant show clusterB -t B_a -gThe
-gparameter displays the primary-standby relationship in a graph. The output is as follows:+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | tenant basic info | +-------------+-------------+--------------------+--------------+---------+---------+-------------+----------+----------+---------------+-------------+-------------+ | tenant_name | tenant_type | compatibility_mode | primary_zone | max_cpu | min_cpu | memory_size | max_iops | min_iops | log_disk_size | iops_weight | tenant_role | +-------------+-------------+--------------------+--------------+---------+---------+-------------+----------+----------+---------------+-------------+-------------+ | B_a | USER | MYSQL | RANDOM | 2.0 | 2.0 | 4G | 10000 | 10000 | 5G | 2 | STANDBY | +-------------+-------------+--------------------+--------------+---------+---------+-------------+----------+----------+---------------+-------------+-------------+ +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | standby tenant standby info | +---------------------+---------------+-----------------+----------------------------+----------+------------------------------------------------------------------------+-------------------+------------------+--------------+ | standby_tenant_name | tenant_status | sync_status | sync_scn_timestamp | err_code | error_comment | switchover_status | switchover_epoch | log_mode | +---------------------+---------------+-----------------+----------------------------+----------+------------------------------------------------------------------------+-------------------+------------------+--------------+ | B_a | NORMAL | RESTORE SUSPEND | 2025-05-27 16:12:08.556291 | 0 | Restore suspend, the log stream has synchronized to recovery until scn | NORMAL | 0 | NOARCHIVELOG | +---------------------+---------------+-----------------+----------------------------+----------+------------------------------------------------------------------------+-------------------+------------------+--------------+ +----------------------------------------------------------------------------------------------------------------------+ | standby tenant`s primary info | +---------------------+------------------------------------------------------------------------------------------------+ | standby_tenant_name | primary_tenant_info | +---------------------+------------------------------------------------------------------------------------------------+ | B_a | oss://oceanbase-test-bucket/backup/log?host=****.aliyun-inc.com&access_id=****&access_key=**** | +---------------------+------------------------------------------------------------------------------------------------+ query primary-standby relation ok primary-standby relation topology graph clusterA:A_a └── clusterB:B_aThe
tenant_statusvalue isNORMAL, and thesync_statusvalue isRESTORE SUSPEND. This indicates that the standby tenant is created and the logs are synchronized to the archive. The following table describes the modules in the output.tenant base info: This table displays the tenant information in the cluster. You need to pay attention to the following items.
Column nameDescriptiontenant_name The name of the tenant. tenant_type The type of the tenant. Valid values: SYSandUSER.compatibility_mode The compatibility mode of the tenant. Valid values: MySQLandOracle. Only the MySQL mode is supported in the Community Edition.primary_zone The primary zone of the tenant. tenant_role The role of the tenant. Valid values: PRIMARY: primary tenantSTANDBY: standby tenantRESTORE: tenant is being restored
standby tenant standby info: This table displays the specific information of the standby tenant in the cluster. You need to pay attention to the following items.
Column nameDescriptionstandby_tenant_name The name of the standby tenant. tenant_status The status of the standby tenant. If the value is NORMAL, the standby tenant is in normal status.sync_status The log synchronization status of the standby tenant. If the value is RESTORE SUSPEND, the logs are synchronized to the archive. After you enable continuous log synchronization for the standby tenant, the value of this column changes toNORMAL, indicating that the log synchronization is normal.sync_scn_timestamp The log synchronization point. err_code The error code of log synchronization. error_comment The error information of log synchronization. switchover_status The primary-standby tenant switchover status. If the value is NORMAL, the primary-standby tenant switchover status is normal.switchover_epoch The time when the primary-standby tenant switchover occurs. log_mode The log archive mode. ARCHIVELOG: archive mode is enabled.NOARCHIVELOG: archive mode is not enabled.
standby tenant`s primary info: This table displays the primary tenant information of the standby tenant in the cluster. You need to pay attention to the following items.
Column nameDescriptionstandby_tenant_name The name of the standby tenant. This column is used to indicate which standby tenant the primary tenant information belongs to. primary_tenant_info The primary tenant information of the standby tenant. When you create a standby tenant based on an archive, this column displays the log archive directory path.
Enable continuous log synchronization
After you create a standby tenant based on an archive, the standby tenant does not continuously synchronize the logs of the primary tenant. Therefore, after the standby tenant is created (the
tenant_statusvalue of theobd cluster tenant showcommand isNORMAL, and thesync_statusvalue isRESTORE SUSPEND), you need to manually run the following command to enable continuous log synchronization for the standby tenant.obd cluster tenant recover clusterB B_aConnect to the primary and standby tenants, modify the information in the primary tenant (A_a), and check whether the standby tenant (B_a) is updated.
Run the following command to create a standby tenant B_a for the primary tenant A_a.
obd cluster tenant create-standby clusterB clusterA A_a --type=LOCATION -t B_a --tenant-root-password=***** -d 'oss://oceanbase-test-bucket/backup/data?host=****.aliyun-inc.com&access_id=****&access_key=****&delete_mode=delete&checksum_type=md5' -a 'oss://oceanbase-test-bucket/backup/log?host=****.aliyun-inc.com&access_id=****&access_key=****&delete_mode=delete&checksum_type=md5'Enable continuous log synchronization
After you create a standby tenant based on an archive, the standby tenant does not continuously synchronize the logs of the primary tenant. Therefore, after the standby tenant is created (the
tenant_statusvalue of theobd cluster tenant showcommand isNORMAL, and thesync_statusvalue isRESTORE SUSPEND), you need to manually run the following command to enable continuous log synchronization for the standby tenant.obd cluster tenant recover clusterB B_aRun the following command to create a standby tenant C_a for the primary tenant A_a.
obd cluster tenant create-standby clusterC clusterA A_a --type=LOCATION -t C_a --tenant-root-password=***** -d 'oss://oceanbase-test-bucket/backup/data?host=****.aliyun-inc.com&access_id=****&access_key=****&delete_mode=delete&checksum_type=md5' -a 'oss://oceanbase-test-bucket/backup/log?host=****.aliyun-inc.com&access_id=****&access_key=****&delete_mode=delete&checksum_type=md5'Enable continuous log synchronization
After you create a standby tenant based on an archive, the standby tenant does not continuously synchronize the logs of the source tenant (the primary tenant or another standby tenant). Therefore, after the standby tenant is created (the
tenant_statusvalue of theobd cluster tenant showcommand isNORMAL, and thesync_statusvalue isRESTORE SUSPEND), you need to manually run the following command to enable continuous log synchronization for the standby tenant.obd cluster tenant recover clusterC C_aRun the following command to view the primary-standby relationship of the standby tenants. In this example, the primary-standby relationship of the clusterB cluster is viewed.
obd cluster tenant show clusterB -t B_a -gThe
-gparameter displays the primary-standby relationship in a graph. The output is as follows:+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | tenant basic info | +-------------+-------------+--------------------+--------------+---------+---------+-------------+----------+----------+---------------+-------------+-------------+ | tenant_name | tenant_type | compatibility_mode | primary_zone | max_cpu | min_cpu | memory_size | max_iops | min_iops | log_disk_size | iops_weight | tenant_role | +-------------+-------------+--------------------+--------------+---------+---------+-------------+----------+----------+---------------+-------------+-------------+ | B_a | USER | MYSQL | RANDOM | 2.0 | 2.0 | 4G | 10000 | 10000 | 5G | 2 | STANDBY | +-------------+-------------+--------------------+--------------+---------+---------+-------------+----------+----------+---------------+-------------+-------------+ +---------------------+---------------+-------------+----------------------------+----------+---------------+-------------------+------------------+--------------+ | standby_tenant_name | tenant_status | sync_status | sync_scn_timestamp | err_code | error_comment | switchover_status | switchover_epoch | log_mode | +---------------------+---------------+-------------+----------------------------+----------+---------------+-------------------+------------------+--------------+ | B_a | NORMAL | NORMAL | 2025-05-27 16:33:28.155249 | 0 | | NORMAL | 0 | NOARCHIVELOG | +---------------------+---------------+-------------+----------------------------+----------+---------------+-------------------+------------------+--------------+ +----------------------------------------------------------------------------------------------------------------------+ | standby tenant`s primary info | +---------------------+------------------------------------------------------------------------------------------------+ | standby_tenant_name | primary_tenant_info | +---------------------+------------------------------------------------------------------------------------------------+ | B_a | oss://oceanbase-test-bucket/backup/log?host=****.aliyun-inc.com&access_id=****&access_key=**** | +---------------------+------------------------------------------------------------------------------------------------+ query primary-standby relation ok primary-standby relation topology graph clusterA:A_a ├── clusterB:B_a └── clusterC:C_aWhen the
tenant_statusandsync_statusvalues in the output are bothNORMAL, the standby tenant is created successfully and the log transmission is normal. For more information about the modules in the output, see Scenario 1: One primary and one standby.Connect to the primary and standby tenants separately. Modify the information in the primary tenant (A_a), and check whether the standby tenants (B_a and C_a) are updated.
Run the following command to create a standby tenant B_a for the A_a tenant:
obd cluster tenant create-standby clusterB clusterA A_a --type=LOCATION -t B_a --tenant-root-password=***** -d 'oss://oceanbase-test-bucket/backup/data?host=****.aliyun-inc.com&access_id=****&access_key=****&delete_mode=delete&checksum_type=md5' -a 'oss://oceanbase-test-bucket/backup/log?host=****.aliyun-inc.com&access_id=****&access_key=****&delete_mode=delete&checksum_type=md5'Run the following command to view the status of the standby tenant:
obd cluster tenant show clusterB -t B_a -gWhen the
tenant_statusvalue isNORMALand thesync_statusvalue isRESTORE SUSPENDin the output, the standby tenant is created successfully and the logs are synchronized to the archive. For more information about the modules in the output, see Scenario 1: One primary and one standby.The
-goption displays the primary/standby relationships in the cluster. The output is as follows:+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | tenant basic info | +-------------+-------------+--------------------+--------------+---------+---------+-------------+----------+----------+---------------+-------------+-------------+ | tenant_name | tenant_type | compatibility_mode | primary_zone | max_cpu | min_cpu | memory_size | max_iops | min_iops | log_disk_size | iops_weight | tenant_role | +-------------+-------------+--------------------+--------------+---------+---------+-------------+----------+----------+---------------+-------------+-------------+ | B_a | USER | MYSQL | RANDOM | 2.0 | 2.0 | 4G | 10000 | 10000 | 5G | 2 | STANDBY | +-------------+-------------+--------------------+--------------+---------+---------+-------------+----------+----------+---------------+-------------+-------------+ +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | standby tenant standby info | +---------------------+---------------+-----------------+----------------------------+----------+------------------------------------------------------------------------+-------------------+------------------+--------------+ | standby_tenant_name | tenant_status | sync_status | sync_scn_timestamp | err_code | error_comment | switchover_status | switchover_epoch | log_mode | +---------------------+---------------+-----------------+----------------------------+----------+------------------------------------------------------------------------+-------------------+------------------+--------------+ | B_a | NORMAL | RESTORE SUSPEND | 2025-05-27 16:12:08.556291 | 0 | Restore suspend, the log stream has synchronized to recovery until scn | NORMAL | 0 | NOARCHIVELOG | +---------------------+---------------+-----------------+----------------------------+----------+------------------------------------------------------------------------+-------------------+------------------+--------------+ +----------------------------------------------------------------------------------------------------------------------+ | standby tenant`s primary info | +---------------------+------------------------------------------------------------------------------------------------+ | standby_tenant_name | primary_tenant_info | +---------------------+------------------------------------------------------------------------------------------------+ | B_a | oss://oceanbase-test-bucket/backup/log?host=****.aliyun-inc.com&access_id=****&access_key=**** | +---------------------+------------------------------------------------------------------------------------------------+ query primary-standby relation ok primary-standby relation topology graph clusterA:A_a └── clusterB:B_aEnable continuous log synchronization.
After a standby tenant is created based on an archive, it does not continuously synchronize logs archived by the primary tenant or another standby tenant. Therefore, after the standby tenant is created successfully (the
tenant_statusvalue isNORMALand thesync_statusvalue isRESTORE SUSPENDin the output of theobd cluster tenant showcommand), run the following command to enable continuous log synchronization for the standby tenant:obd cluster tenant recover clusterB B_aRun the following command to create a standby tenant C_a for the B_a tenant:
Note
It is recommended that you create the C_a tenant after the B_a tenant is synchronized.
obd cluster tenant create-standby clusterC clusterB B_a --type=LOCATION -t C_a --tenant-root-password=***** -d 'oss://oceanbase-test-bucket/backup/data?host=****.aliyun-inc.com&access_id=****&access_key=****&delete_mode=delete&checksum_type=md5' -a 'oss://oceanbase-test-bucket/backup/log?host=****.aliyun-inc.com&access_id=****&access_key=****&delete_mode=delete&checksum_type=md5'Enable continuous log synchronization.
After a standby tenant is created based on an archive, it does not continuously synchronize logs archived by the primary tenant or another standby tenant. Therefore, after the standby tenant is created successfully (the
tenant_statusvalue isNORMALand thesync_statusvalue isRESTORE SUSPENDin the output of theobd cluster tenant showcommand), run the following command to enable continuous log synchronization for the standby tenant:obd cluster tenant recover clusterB B_aRun the following command to view the primary/standby relationships of the standby tenant. Here is an example of viewing the primary/standby relationships in the clusterB cluster:
obd cluster tenant show clusterB -t B_a -gThe
-goption displays the primary/standby relationships in the cluster. The output is as follows:+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | tenant basic info | +-------------+-------------+--------------------+--------------+---------+---------+-------------+----------+----------+---------------+-------------+-------------+ | tenant_name | tenant_type | compatibility_mode | primary_zone | max_cpu | min_cpu | memory_size | max_iops | min_iops | log_disk_size | iops_weight | tenant_role | +-------------+-------------+--------------------+--------------+---------+---------+-------------+----------+----------+---------------+-------------+-------------+ | B_a | USER | MYSQL | RANDOM | 2.0 | 2.0 | 4G | 10000 | 10000 | 5G | 2 | STANDBY | +-------------+-------------+--------------------+--------------+---------+---------+-------------+----------+----------+---------------+-------------+-------------+ +---------------------+---------------+-------------+----------------------------+----------+---------------+-------------------+------------------+--------------+ | standby_tenant_name | tenant_status | sync_status | sync_scn_timestamp | err_code | error_comment | switchover_status | switchover_epoch | log_mode | +---------------------+---------------+-------------+----------------------------+----------+---------------+-------------------+------------------+--------------+ | B_a | NORMAL | NORMAL | 2025-05-27 16:33:28.155249 | 0 | | NORMAL | 0 | NOARCHIVELOG | +---------------------+---------------+-------------+----------------------------+----------+---------------+-------------------+------------------+--------------+ +----------------------------------------------------------------------------------------------------------------------+ | standby tenant`s primary info | +---------------------+------------------------------------------------------------------------------------------------+ | standby_tenant_name | primary_tenant_info | +---------------------+------------------------------------------------------------------------------------------------+ | B_a | oss://oceanbase-test-bucket/backup/log?host=****.aliyun-inc.com&access_id=****&access_key=**** | +---------------------+------------------------------------------------------------------------------------------------+ query primary-standby relation ok primary-standby relation topology graph clusterA:A_a └── clusterB:B_a └── clusterC:C_aConnect to the primary and standby tenants separately. Modify the information in the primary tenant (A_a), and check whether the standby tenants (B_a and C_a) are updated.
FAQ
Error occurs when you create a standby tenant: primary cluster have not full log xxx
Cause: The primary cluster does not have full logs.
Network-based primary-standby synchronization requires the primary cluster to have full logs. Therefore, when you execute the command to create a standby tenant, obd checks whether the BEGIN_LSN value of the log stream in the primary cluster is 0. If the BEGIN_LSN value is 0, it indicates that the log stream replica has complete logs since its creation. If the BEGIN_LSN value is not 0, obd cannot create a standby tenant based on network synchronization.
Solution: Log in to the primary cluster and execute the following command to query whether the BEGIN_LSN value of the log stream is 0.
SELECT LS_ID, BEGIN_LSN FROM oceanbase.GV$OB_LOG_STAT WHERE ROLE = 'LEADER' ;
If the BEGIN_LSN value of the log stream in the primary cluster is not 0, it indicates that the primary cluster does not have full logs. In this case, you cannot use obd to create a standby tenant for the primary cluster.
References
For information about how to perform data backup and log archiving by using obd commands, see Backup and restore.
For information about how to perform primary-standby switching or decoupling by using obd commands, see Role switching and decoupling.
For information about how to switch the primary-standby synchronization method by using obd commands, see Switch the primary-standby tenant synchronization method.
