This topic describes how to change standard OceanBase Cloud Platform (OCP) clusters into leader and follower OCP clusters in multi-cluster mode.
Prerequisites
OCP clusters of V3.1.1 or later versions have been installed. Notice
The OceanBase clusters managed by the OCP clusters must have different names. Otherwise, follower OCP clusters cannot be registered in the leader OCP cluster.
Procedure
Run the
docker exec -it ocp bashcommand to enter the OCP container.Run the
env | grep -i metadbcommand to check whether the following MetaDB environment variables are set.OCP_METADB_HOST OCP_METADB_PORT OCP_METADB_USER OCP_METADB_PASSWORD OCP_METADB_DBNAMEIf not, run the following command to set the MetaDB environment viarables:
# The following example variables are provided for your reference only. You need to change the values based on the actual situation. export OCP_METADB_HOST="192.168.0.1" export OCP_METADB_PORT="2881" export OCP_METADB_USER="ocp@ocp_meta" export OCP_METADB_PASSWORD="******" export OCP_METADB_DBNAME="meta_01"Run the
cd /home/admin/ocp-init/src/ocp-initcommand to go to the directory where the modify_mc_config.py script is stored.You can perform one of the following steps to restructure your OCP cluster as needed:
Run the following command in the required OCP cluster to change it into the leader OCP cluster.
python modify_mc_config.py --multicluster_mode_enabled=true --cluster_id=xxx --cluster_name=xxx --cluster_role=LEADERRun the following command in the required OCP cluster to change it into a follower OCP cluster.
python modify_mc_config.py --multicluster_mode_enabled=true --cluster_id=xxx --cluster_name=xxx --cluster_role=FOLLOWERAfter a failover, run the following command in the original leader OCP cluster to change it into an unregistered follower OCP cluster that can be registered with the new leader OCP cluster.
python modify_mc_config.py --cluster_role=FOLLOWER --register_status=UNREGISTERED
Note
The modify_mc_config.py script supports the following parameters:
--multicluster_mode_enabled: specifies whether to enable multi-cluster mode. Valid values: true and false.
--cluster_id: specifies the ID of the OCP cluster. The type of the cluster ID is integral.
Make sure that each OCP cluster has a unique ID.
--cluster_name: the OCP cluster name. Type: string.
-- cluster_role: the role of the OCP cluster. Valid values: LEADER and FOLLOWER.
Make sure that only one leader OCP cluster exists.
--register_status: the registration status of the OCP cluster. Valid values: REGISTERED and UNREGISTERED. After a failover, if the original leader OCP cluster is recovered, you can register it with the new leader OCP cluster as a follower cluster. To do this, change its registration status to UNREGISTERED and its role to FOLLOWER. See the third command in the preceding Step 4.
Restart the OCP cluster.
Run the
docker restart ocpcommand on the OCP host.If two or more OCP instances are deployed in the OCP cluster, restart all OCP instances.