This topic describes how to use OceanBase Shell (OBShell) to take over an OceanBase cluster with three replicas deployed by OceanBase Cloud Platform (OCP). OBShell can take over an OceanBase cluster in any state.
Deployment mode
In this topic, the following three machines are used:
| Role | Machine | Remarks |
|---|---|---|
| OBServer node | 10.10.10.1 | In OceanBase Database Zone 1 |
| OBServer node | 10.10.10.2 | In OceanBase Database Zone 2 |
| OBServer node | 10.10.10.3 | In OceanBase Database Zone 3 |
Procedure
Step 1: Set the environment variable for the tenant password
If the root user of the sys tenant in the OceanBase cluster has a password, run the following command on any OBServer node to obtain the tenant password for OBShell. For example, the IP address of the OBServer node to use is 10.10.10.1.
[admin@test001 ~]$ export OB_ROOT_PASSWORD="pwd"
Step 2: Take over the cluster
Run the following command on the OBServer node (10.10.10.1) to start OBShell for each OBServer node in the current OceanBase cluster and perform the takeover. OBShell is installed in the /home/admin/oceanbase/bin/obshell directory. For more information about the command, see obshell cluster start.
[admin@test001 ~]$ /home/admin/oceanbase/bin/obshell cluster start -a
Step 3: Check whether the takeover is successful
Call the /api/v1/ob/info API operation on any OBServer node where OBShell is stored. In the returned agent_info, if the value of identity is CLUSTER AGENT, the current OceanBase cluster is taken over by OBShell. For more information, see GetObInfo.
Note
OBShell verifies the security of requested API operations. Therefore, you must encrypt the request before you call an API operation. For more information, see Hybrid encryption for API operations. You must also specify ${request_headers} and ${request_body} in the curl command.
Run the following command:
[admin@test001 ~]$ curl -H 'X-OCS-Header:${request_headers}' -X GET http://10.10.10.1:2886/api/v1/ob/infoHere is a sample result:
{ ....... "agent_info": [ { "ip": "10.10.10.1", "identity": "CLUSTER AGENT", ... }, { "ip": "10.10.10.2", "identity": "CLUSTER AGENT", ... }, { "ip": "10.10.10.3", "identity": "CLUSTER AGENT", ... } ], ... }
Note
If the OceanBase cluster is managed by OBShell, the takeover is successful.