This topic describes how to use OceanBase Shell (obshell) to stop an OceanBase cluster with three replicas.
Prerequisites
The OceanBase cluster is managed by obshell. For more information, see Take over an OceanBase cluster not deployed by obshell.
All OBServer nodes and obshell processes in the OceanBase cluster are running normally.
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 |
Stop an OceanBase cluster by calling the relevant 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/stop API operation in any obshell process in the cluster to stop an OceanBase cluster.
For more information about how to call the corresponding API operation by using the CLI, see StopCluster.
For more information about how to call the corresponding API operation by using obshell-sdk-python, see Stop a cluster.
For more information about how to call the corresponding API operation by using obshell-sdk-go, see Stop a cluster.
Scenario 1: Stop all 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/stop
The content of the request body before encryption is as follows:
{
"scope": {
"type": "GLOBAL",
"target": ""
},
"force": true}
···
client = ClientSeta("10.10.10.1", 2886, PasswordAuth("****"))
client.v1.stop_sync("GLOBAL", None, force=True) ## Call /api/v1/ob/stop.
···
···
client, err := services.NewClientWithPassword("10.10.10.1", 2886, "****")
req := client.V1().NewStopRequest(v1.SCOPE_GLOBAL).SetForce()
dag, err := client.V1().StopSyncWithRequest(req) // Call /api/v1/ob/stop.
···
Scenario 2: Stop 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/stop
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"
},
"force": true}
···
client = ClientSet("10.10.10.1", 2886, PasswordAuth("****"))
client.v1.stop_sync("GLOBAL", None, force=True) ## Call /api/v1/ob/stop.
···
···
client, err := services.NewClientWithPassword("10.10.10.1", 2886, "****")
req := client.V1().NewStopRequest(v1.SERVER, "10.10.10.1:2886,10.10.10.2:2886").SetForce()
dag, err := client.V1().StopSyncWithRequest(req) // Call /api/v1/ob/stop.
···
Scenario 3: Stop 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/stop
The content of the request body before encryption is as follows:
{
"scope": {
"type": "ZONE",
"target": "zone1"
},
"force": true}
···
client = ClientSet("10.10.10.1", 2886, PasswordAuth("****"))
client.v1.stop_sync("ZONE", "zone1", force=True) ## Call /api/v1/ob/stop.
···
···
client, err := services.NewClientWithPassword("10.10.10.1", 2886, "****")
req := client.V1().NewStopRequest(v1.SCOPE_ZONE, "zone1").SetForce()
dag, err := client.V1().StopSyncWithRequest(req) // Call /api/v1/ob/stop.
···
Scenario 4: Isolate an OBServer node
[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/stop
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.stop_sync("SERVER", "10.10.10.1:2886,10.10.10.2:2886") ## Call /api/v1/ob/stop.
···
···
client, err := services.NewClientWithPassword("10.10.10.1", 2886, "****")
req := client.V1().NewStopRequest(v1.SCOPE_SERVER, "10.10.10.1:2886,10.10.10.2:2886")
dag, err := client.V1().StopSyncWithRequest(req) // Call /api/v1/ob/stop.
···
Scenario 5: Isolate a zone
[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/stop
The content of the request body before encryption is as follows:
{
"scope": {
"type": "ZONE",
"target": "zone1"
}}
···
client = ClientSet("10.10.10.1", 2886, PasswordAuth("****"))
client.v1.stop_sync("ZONE", "zone1") ## Call /api/v1/ob/stop.
···
···
client, err := services.NewClientWithPassword("10.10.10.1", 2886, "****")
req := client.V1().NewStopRequest(v1.SCOPE_ZONE, "zone1")
dag, err := client.V1().StopSyncWithRequest(req) // Call /api/v1/ob/stop.
···
Stop an OceanBase cluster by running obshell commands
Scenario 1: Stop all observer processes
Run the following command on any OBServer node to stop the observer processes on all OBServer nodes. For more information, see obshell cluster stop.
[admin@test001 ~]$ /home/admin/oceanbase/bin/obshell cluster stop -a -f
Scenario 2: Stop specified observer processes
Run the following command on any OBServer node to stop the specified observer processes. For more information, see obshell cluster stop.
[admin@test001 ~]$ /home/admin/oceanbase/bin/obshell cluster stop -s 10.10.10.1:2886,10.10.10.2:2886 -f
Scenario 3: Stop the observer processes in specified zones
Run the following command on any OBServer node to stop the observer processes in specified zones. For more information, see obshell cluster stop.
[admin@test001 ~]$ /home/admin/oceanbase/bin/obshell cluster stop -z zone1 -f
Scenario 4: Isolate an OBServer node
Run the following command on any OBServer node to isolate one or more OBServer nodes. For more information, see obshell cluster stop.
[admin@test001 ~]$ /home/admin/oceanbase/bin/obshell cluster stop -s 10.10.10.1:2886 -I
Scenario 5: Isolate a zone
Run the following command on any OBServer node to isolate one or more zones. For more information, see obshell cluster stop.
[admin@test001 ~]$ /home/admin/oceanbase/bin/obshell cluster stop -z zone1 -I
References
For more information about the
STOP ZONEcommand, see Isolate a zone.For more information about the
STOP SERVERcommand, see Isolate a node.