OceanBase Shell (OBShell) supports the following cluster scale-out methods:
Scale out a cluster by calling the relevant API operation
Scale out a cluster by using the CLI
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 | Remarks |
|---|---|---|
| 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 a cluster by calling the relevant 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. For more information, see Start OBShell.
[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, 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
Step 3: Check whether the scale-out is successful
Log on 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 result 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 result 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 a tenant
After you successfully scale out the OceanBase cluster, you can scale out the tenants in the cluster. For more information, see Overview.
Scale out a cluster by using the CLI
Step 1: Start OBShell
Start OBShell on the OBServer node (10.10.10.4) to be added to the cluster. For more information, see Start OBShell.
[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. For more information, see obshell cluster scale-out.
[admin@test004 ~]$ /home/admin/oceanbase/bin/obshell cluster scale-out -s '10.10.10.4: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 on 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 result 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 result 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 a tenant
After you successfully scale out the OceanBase cluster, you can scale out the tenants in the cluster. For more information, see Overview.