OceanBase Shell (obshell) supports the following cluster scale-out methods:
Scale out an OceanBase cluster by calling the corresponding API operation
Scale out an OceanBase cluster by running obshell commands
This topic describes how to use obshell to scale out 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 existing machines in the OceanBase cluster and the machine to be added, with obshell using the default port 2886.
| Role | Machine | Description |
|---|---|---|
| Existing OBServer node | 10.10.10.1 | In OceanBase Database Zone 1 |
| Existing OBServer node | 10.10.10.2 | In OceanBase Database Zone 2 |
| Existing OBServer node | 10.10.10.3 | In OceanBase Database Zone 3 |
| OBServer node to be added | 10.10.10.4 | To be added to OceanBase Database Zone 1 |
Scale out an OceanBase cluster by calling the corresponding API operation
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.
Step 1: Start obshell
Start obshell on the OBServer node (10.10.10.4) to be added to the cluster.
[admin@test004 ~]$ /home/admin/oceanbase/bin/obshell agent start --ip 10.10.10.4 -P 2886
Step 2: Call the scale-out API operation
Call the /api/v1/ob/scale_out API operation in any obshell process in the cluster to initiate a scale-out.
For more information about how to call the corresponding API operation by using the CLI, see AddNode. The API operation creates an asynchronous O&M task. For more information about how to query the task progress, see GetDagDetails. Wait for the scale-out task to complete.
[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/scale_out
For more information about how to call the corresponding API operation by using obshell-sdk-python, see Scale out a cluster.
···
client = ClientSet("10.10.10.1", 2886, PasswordAuth("****"))
configs = {"redoDir":" /data/workspace/redo", "dataDir":" /data/workspace/data",
"datafile_size":"24G", "cpu_count":"16", "memory_limit":"16G",
"system_memory":"4G", "log_disk_size":"40G"}
client.v1.scale_out_sync("10.10.10.4", 2886, "zone1", configs) ## Call /api/v1/ob/scale_out.
···
For more information about how to call the corresponding API operation by using obshell-sdk-go, see Scale out a cluster.
···
client, err := services.NewClientWithPassword("10.10.10.1", 2886, "****")
configs := map[string]string {
"redoDir":" /data/workspace/redo", "dataDir":" /data/workspace/data",
"datafile_size":"24G", "cpu_count":"16", "memory_limit":"16G",
"system_memory":"4G", "log_disk_size":"40G"}
req := client.V1().NewScaleOutRequest("10.10.10.4", 2886, "zone1", configs)
dag, err := client.V1().ScaleOutSyncWithRequest(req) // Call /api/v1/ob/scale_out.
···
Step 3: Check whether the scale-out is successful
Log in to the
systenant of OceanBase Database as therootuser, and run the following command to query all OBServer nodes in the cluster:obclient [oceanbase]> select * from oceanbase.dba_ob_servers;The output is as follows:
+------------+----------+----+-------+----------+-----------------+--------+----------------------------+-----------+-----------------------+----------------------------+----------------------------+-------------------------------------------------------------------------------------------+-------------------+ | SVR_IP | SVR_PORT | ID | ZONE | SQL_PORT | WITH_ROOTSERVER | STATUS | START_SERVICE_TIME | STOP_TIME | BLOCK_MIGRATE_IN_TIME | CREATE_TIME | MODIFY_TIME | BUILD_VERSION | LAST_OFFLINE_TIME | +------------+----------+----+-------+----------+-----------------+--------+----------------------------+-----------+-----------------------+----------------------------+----------------------------+-------------------------------------------------------------------------------------------+-------------------+ | 10.10.10.1 | 2882 | 1 | zone1 | 2881 | YES | ACTIVE | 2024-04-09 17:47:47.849965 | NULL | NULL | 2024-04-09 17:47:42.054759 | 2024-04-09 17:47:48.850012 | 4.3.0.1_100000242024032211-0193a343bc60b4699ec47792c3fc4ce166a182f9(Mar 22 2024 13:19:48) | NULL | | 10.10.10.2 | 2882 | 2 | zone2 | 2881 | NO | ACTIVE | 2024-04-09 17:47:47.749100 | NULL | NULL | 2024-04-09 17:47:42.173519 | 2024-04-09 17:47:48.850012 | 4.3.0.1_100000242024032211-0193a343bc60b4699ec47792c3fc4ce166a182f9(Mar 22 2024 13:19:48) | NULL | | 10.10.10.3 | 2882 | 3 | zone3 | 2881 | NO | ACTIVE | 2024-04-09 17:47:47.490511 | NULL | NULL | 2024-04-09 17:47:42.567437 | 2024-04-09 17:47:48.850012 | 4.3.0.1_100000242024032211-0193a343bc60b4699ec47792c3fc4ce166a182f9(Mar 22 2024 13:19:48) | NULL | | 10.10.10.4 | 2882 | 4 | zone1 | 2881 | NO | ACTIVE | 2024-04-10 10:37:47.530894 | NULL | NULL | 2024-04-09 10:27:32.222980 | 2024-04-09 17:47:48.850012 | 4.3.0.1_100000242024032211-0193a343bc60b4699ec47792c3fc4ce166a182f9(Mar 22 2024 13:19:48) | NULL | +------------+----------+----+-------+----------+-----------------+--------+----------------------------+-----------+-----------------------+----------------------------+----------------------------+-------------------------------------------------------------------------------------------+-------------------+Run the following command to query the OBServer nodes managed by obshell:
obclient [oceanbase]> select * from ocs.all_agent;The output is as follows:
+------------+------+---------------+----------------------+-------+--------------+-------+------------+----------+--------------------------+------------------------------------------------------------------------------------------------------+ | ip | port | identity | version | os | architecture | zone | mysql_port | rpc_port | home_path | public_key | +------------+------+---------------+----------------------+-------+--------------+-------+------------+----------+--------------------------+------------------------------------------------------------------------------------------------------+ | 10.10.10.1 | 2886 | CLUSTER AGENT | 4.2.3.0-102024031414 | linux | x86_64 | zone1 | 2881 | 2882 | /home/admin/oceanbase-ce | MEgCQQCfqaND/dAbH/cJhOuTP8gRUBZh1nqrNtFwB9Plw6YwWiSintZPiC9pN/FKlBeR/Klt2jvu8oqZe+S3p/xq+ckPAgMBAAE= | | 10.10.10.2 | 2886 | CLUSTER AGENT | 4.2.3.0-102024031414 | linux | x86_64 | zone2 | 2881 | 2882 | /home/admin/oceanbase-ce | MEgCQQCfqaND/dAbH/cJhOuTP8gRUBZh1nqrNtFwB9Plw6YwWiSintZPiC9pN/FKlBeR/Klt2jvu8oqZe+S3p/xq+ckPAgMBAAE= | | 10.10.10.3 | 2886 | CLUSTER AGENT | 4.2.3.0-102024031414 | linux | x86_64 | zone3 | 2881 | 2882 | /home/admin/oceanbase-ce | MEgCQQCfqaND/dAbH/cJhOuTP8gRUBZh1nqrNtFwB9Plw6YwWiSintZPiC9pN/FKlBeR/Klt2jvu8oqZe+S3p/xq+ckPAgMBAAE= | | 10.10.10.4 | 2886 | CLUSTER AGENT | 4.2.3.0-102024031414 | linux | x86_64 | zone1 | 2881 | 2882 | /home/admin/oceanbase-ce | MEgCQQCfqaND/dAbH/cJhOuTP8gRUBZh1nqrNtFwB9Plw6YwWiSintZPiC9pN/FKlBeR/Klt2jvu8oqZe+S3p/xq+ckPAgMBAAE= | +------------+------+---------------+----------------------+-------+--------------+-------+------------+----------+--------------------------+------------------------------------------------------------------------------------------------------+
If both commands return the information about the OBServer node added to the cluster, the scale-out is successful.
Step 4: Scale out the resources in tenants
After you successfully scale out the OceanBase cluster, you can scale out the resources in tenants. For more information, see Overview.
Scale out an OceanBase cluster by running obshell commands
Step 1: Start obshell
Start obshell on the OBServer node (10.10.10.4) to be added to the cluster.
[admin@test004 ~]$ /home/admin/oceanbase/bin/obshell agent start --ip 10.10.10.4 -P 2886
Step 2: Run the scale-out command to perform a scale-out
Run the scale-out command on the OBServer node to be added to perform a scale-out. Run the obshell cluster scale-out command on the OBServer node (10.10.10.4) to be added.
[admin@test004 ~]$ /home/admin/oceanbase/bin/obshell cluster scale-out -s '10.10.10.1:2886' -z 'zone1' -o 'memory_limit=16G,system_memory=8G,log_disk_size=24G,datafile_size=24G' --rp *****
Step 3: Check whether the scale-out is successful
Log in to the
systenant of OceanBase Database as therootuser, and run the following command to query all OBServer nodes in the cluster:obclient [oceanbase]> select * from oceanbase.dba_ob_servers;The output is as follows:
+------------+----------+----+-------+----------+-----------------+--------+----------------------------+-----------+-----------------------+----------------------------+----------------------------+-------------------------------------------------------------------------------------------+-------------------+ | SVR_IP | SVR_PORT | ID | ZONE | SQL_PORT | WITH_ROOTSERVER | STATUS | START_SERVICE_TIME | STOP_TIME | BLOCK_MIGRATE_IN_TIME | CREATE_TIME | MODIFY_TIME | BUILD_VERSION | LAST_OFFLINE_TIME | +------------+----------+----+-------+----------+-----------------+--------+----------------------------+-----------+-----------------------+----------------------------+----------------------------+-------------------------------------------------------------------------------------------+-------------------+ | 10.10.10.1 | 2882 | 1 | zone1 | 2881 | YES | ACTIVE | 2024-04-09 17:47:47.849965 | NULL | NULL | 2024-04-09 17:47:42.054759 | 2024-04-09 17:47:48.850012 | 4.3.0.1_100000242024032211-0193a343bc60b4699ec47792c3fc4ce166a182f9(Mar 22 2024 13:19:48) | NULL | | 10.10.10.2 | 2882 | 2 | zone2 | 2881 | NO | ACTIVE | 2024-04-09 17:47:47.749100 | NULL | NULL | 2024-04-09 17:47:42.173519 | 2024-04-09 17:47:48.850012 | 4.3.0.1_100000242024032211-0193a343bc60b4699ec47792c3fc4ce166a182f9(Mar 22 2024 13:19:48) | NULL | | 10.10.10.3 | 2882 | 3 | zone3 | 2881 | NO | ACTIVE | 2024-04-09 17:47:47.490511 | NULL | NULL | 2024-04-09 17:47:42.567437 | 2024-04-09 17:47:48.850012 | 4.3.0.1_100000242024032211-0193a343bc60b4699ec47792c3fc4ce166a182f9(Mar 22 2024 13:19:48) | NULL | | 10.10.10.4 | 2882 | 4 | zone1 | 2881 | NO | ACTIVE | 2024-04-10 10:37:47.530894 | NULL | NULL | 2024-04-09 10:27:32.222980 | 2024-04-09 17:47:48.850012 | 4.3.0.1_100000242024032211-0193a343bc60b4699ec47792c3fc4ce166a182f9(Mar 22 2024 13:19:48) | NULL | +------------+----------+----+-------+----------+-----------------+--------+----------------------------+-----------+-----------------------+----------------------------+----------------------------+-------------------------------------------------------------------------------------------+-------------------+Run the following command to query the OBServer nodes managed by obshell:
obclient [oceanbase]> select * from ocs.all_agent;The output is as follows:
+------------+------+---------------+----------------------+-------+--------------+-------+------------+----------+--------------------------+------------------------------------------------------------------------------------------------------+ | ip | port | identity | version | os | architecture | zone | mysql_port | rpc_port | home_path | public_key | +------------+------+---------------+----------------------+-------+--------------+-------+------------+----------+--------------------------+------------------------------------------------------------------------------------------------------+ | 10.10.10.1 | 2886 | CLUSTER AGENT | 4.2.3.0-102024031414 | linux | x86_64 | zone1 | 2881 | 2882 | /home/admin/oceanbase-ce | MEgCQQCfqaND/dAbH/cJhOuTP8gRUBZh1nqrNtFwB9Plw6YwWiSintZPiC9pN/FKlBeR/Klt2jvu8oqZe+S3p/xq+ckPAgMBAAE= | | 10.10.10.2 | 2886 | CLUSTER AGENT | 4.2.3.0-102024031414 | linux | x86_64 | zone2 | 2881 | 2882 | /home/admin/oceanbase-ce | MEgCQQCfqaND/dAbH/cJhOuTP8gRUBZh1nqrNtFwB9Plw6YwWiSintZPiC9pN/FKlBeR/Klt2jvu8oqZe+S3p/xq+ckPAgMBAAE= | | 10.10.10.3 | 2886 | CLUSTER AGENT | 4.2.3.0-102024031414 | linux | x86_64 | zone3 | 2881 | 2882 | /home/admin/oceanbase-ce | MEgCQQCfqaND/dAbH/cJhOuTP8gRUBZh1nqrNtFwB9Plw6YwWiSintZPiC9pN/FKlBeR/Klt2jvu8oqZe+S3p/xq+ckPAgMBAAE= | | 10.10.10.4 | 2886 | CLUSTER AGENT | 4.2.3.0-102024031414 | linux | x86_64 | zone1 | 2881 | 2882 | /home/admin/oceanbase-ce | MEgCQQCfqaND/dAbH/cJhOuTP8gRUBZh1nqrNtFwB9Plw6YwWiSintZPiC9pN/FKlBeR/Klt2jvu8oqZe+S3p/xq+ckPAgMBAAE= | +------------+------+---------------+----------------------+-------+--------------+-------+------------+----------+--------------------------+------------------------------------------------------------------------------------------------------+
If both commands return the information about the OBServer node added to the cluster, the scale-out is successful.
Step 4: Scale out the resources in tenants
After you successfully scale out the OceanBase cluster, you can scale out the resources in tenants. For more information, see Overview.