This topic describes how to use OceanBase Shell (obshell) to start an OceanBase cluster with three replicas. The procedure varies with the management status of the OceanBase cluster:
OceanBase cluster managed by obshell
OceanBase cluster not managed by obshell
For more information about how to check whether an OceanBase cluster is managed by obshell, see Step 3 in Take over an OceanBase cluster not deployed by obshell.
Deployment mode
The following table describes the three machines.
| Role | Machine | Description |
|---|---|---|
| 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 |
OceanBase cluster managed by obshell
Prerequisites
All obshell processes are running normally. For more information, see Start or stop obshell.
Start an OceanBase cluster by calling the corresponding API operation
Note
When you call API operations by using the CLI, take note of the following considerations:
The following API operation creates an asynchronous task. You must wait until the current task is completed before you can proceed to the next step. For more information, see GetDagDetails.
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 thecurlcommand.
You can call the /api/v1/ob/start API operation in any obshell process in the cluster to start observer processes.
For more information about how to call the corresponding API operation by using the CLI, see StartCluster.
For more information about how to call the corresponding API operation by using obshell-sdk-python, see Start a cluster.
For more information about how to call the corresponding API operation by using obshell-sdk-go, see Start a cluster.
Scenario 1: Start all observer processes in the cluster
[admin@test001 ~]$ curl -H "Content-Type: application/json" -X POST -d '${request_body}' http://10.10.10.1:2886/api/v1/ob/start
The content of the request body before encryption is as follows:
{
"scope": {
"type": "GLOBAL",
"target": ""
}}
···
client = ClientSet("10.10.10.1", 2886, PasswordAuth("****"))
client.v1.start_sync("GLOBAL", None) # Call /api/v1/ob/start.
···
···
client, err := services.NewClientWithPassword("10.10.10.1", 2886, "****")
req := client.V1().NewStartRequest(v1.SCOPE_GLOBAL)
dag, err := client.V1().StartSyncWithRequest(req) // Call /api/v1/ob/start.
···
Scenario 2: Start specified observer processes
[admin@test001 ~]$ curl -H "Content-Type: application/json" -H 'X-OCS-Header:${request_headers}' -X POST -d '${request_body}' http://10.10.10.1:2886/api/v1/ob/start
The content of the request body before encryption is as follows:
{
"scope": {
"type": "SERVER",
"target": "10.10.10.1:2886,10.10.10.2:2886"
}}
···
client = ClientSet("10.10.10.1", 2886, PasswordAuth("****"))
client.v1.start_sync("SERVER", "10.10.10.1:2886,10.10.10.2:2886") # Call /api/v1/ob/start.
···
···
client, err := services.NewClientWithPassword("10.10.10.1", 2886, "****")
req := client.V1().NewStartRequest(v1.SCOPE_SERVER, "10.10.10.1:2886,10.10.10.2:2886")
dag, err := client.V1().StartSyncWithRequest(req) // Call /api/v1/ob/start.
···
Scenario 3: Start the observer processes in specified zones
[admin@test001 ~]$ curl -H "Content-Type: application/json" -H 'X-OCS-Header:${request_headers}' -X POST -d '${request_body}' http://10.10.10.1:2886/api/v1/ob/start
The content of the request body before encryption is as follows:
{
"scope": {
"type": "ZONE",
"target": "zone1,zone2"
}}
···
client = ClientSet("10.10.10.1", 2886, PasswordAuth("****"))
client.v1.start_sync("ZONE", "zone1,zone2") # Call /api/v1/ob/start.
···
···
client, err := services.NewClientWithPassword("10.10.10.1", 2886, "****")
req := client.V1().NewStartRequest(v1.SCOPE_ZONE, "zone1,zone2")
dag, err := client.V1().StartSyncWithRequest(req) // Call /api/v1/ob/start.
···
Start an OceanBase cluster by running obshell commands
Scenario 1: Start all observer processes in the cluster
Run the following command on any OBServer node to start all observer processes. For more information, see obshell cluster start.
[admin@test001 ~]$ /home/admin/oceanbase/bin/obshell cluster start -a
Scenario 2: Start specified observer processes
Run the following command on any OBServer node to start the specified observer processes. For more information, see obshell cluster start.
[admin@test001 ~]$ /home/admin/oceanbase/bin/obshell cluster start -s 10.10.10.1:2886,10.10.10.2:2886
Scenario 3: Start the observer processes in specified zones
Run the following command on any OBServer node to start the observer processes in the specified zones. For more information, see obshell cluster start.
[admin@test001 ~]$ /home/admin/oceanbase/bin/obshell cluster start -z zone1,zone2
OceanBase cluster not managed by obshell
In this case, the cluster is not managed by obshell and must be taken over by obshell. During the takeover, all observer processes are started to restore the cluster. For more information, see Take over an OceanBase cluster not deployed by obshell.
References
For more information about how to start an OBServer node by using SQL commands, see Step 7 in Restart a node.
For more information about how to start a zone by using SQL commands, see Start a zone.