You can add a node to an OceanBase cluster for elastic scaling or deployment adjustment.
Elastic scaling scenario: After the addition, more nodes are available in the zone to accommodate units. This enables you to migrate units and adjust the values of
UNIT_NUMand create new tenants.Adjust the deployment scenario: Adjust the deployment scenario, including changing the cluster deployment mode from a three-center setup within the same city to a five-center setup across three regions, as well as relocating Zones from one data center to another in the event of data center closure. This scenario requires first adding a Zone, then adding nodes within that Zone, and subsequently adjusting the Locality attributes of the tenant.
The elastic scaling feature of OceanBase Database offers a clear architecture advantage over traditional databases. In a traditional database, data is stored on a single server. OceanBase Database can distribute data across multiple servers to address scalability challenges and leverage the advantages of the distributed architecture. When the capacity of a cluster or a tenant is insufficient, you can add more nodes to the cluster to accommodate more tenants, or add nodes to a tenant to accommodate more data and business traffic. Conversely, when the capacity of a cluster or a tenant is excessive, you can remove nodes from the cluster or the tenant to reduce costs.
The multi-replica deployment feature of OceanBase Database offers another clear architecture advantage over traditional databases. Multi-replica deployment is the basis for lossless disaster recovery at multiple levels, including lossless disaster recovery at the standalone, IDC, and region levels. In addition, OceanBase Database allows you to flexibly adjust the deployment architecture of a cluster to adapt to technological advancements in business scenarios.
Prerequisites
You have confirmed that all OBServer nodes to be added are properly configured. For more information, see Prepare servers.
You have installed the database software on all OBServer nodes. You can download the OceanBase Database software package from the OceanBase Download Center or obtain it from OceanBase Technical Support.
Procedure
Note
In this section, you will learn how to manually add a node to a cluster by using a command. If you use OceanBase Database Community Edition and want to add a node to an OceanBase cluster by using OBD, refer to the Scale out section in the OBD documentation.
(Optional) If you want to add a node to a zone later, make sure that the zone has been added. For more information, see Add a zone.
Use
sshto log in to the OBServer node to be added, initialize the OBServer node, and configure the clock source.For more information about how to initialize the OBServer node, see Initialize an OBServer node by using oat-cli.
For more information about how to configure the clock source, see Configure the clock source.
Use
sshto log in to the OBServer node to be added, and install the RPM package of OceanBase Database.Before you add a node, install the database software on all OBServer nodes to be added.
The command is as follows:
[root@xxx /]#cd $rpm_dir [root@xxx $rpm_dir]#rpm -ivh $rpm_nameHere,
rpm_dirindicates the directory where the RPM package is stored;$rpm_nameindicates the name of the RPM package.Initialize the directory of OceanBase Database.
We recommend that you set the data directory of OceanBase Database on a separate disk and then create a soft link to the
Homedirectory of the software.[root@xxx admin]#su - admin -bash-4.2$ mkdir -p /data/1/$cluster_name/{etc3,sort_dir,sstable,slog} -bash-4.2$ mkdir -p /data/log1/$cluster_name/{clog,etc2,ilog,oob_clog} -bash-4.2$ mkdir -p /home/admin/oceanbase/store/$cluster_name -bash-4.2$ for t in {etc3,sort_dir,sstable,slog};do ln -s /data/1/$cluster_name/$t /home/admin/oceanbase/store/$cluster_name/$t; done -bash-4.2$ for t in {clog,etc2,ilog,oob_clog};do ln -s /data/log1/$cluster_name/$t /home/admin/oceanbase/store/$cluster_name/$t; doneHere,
cluster_nameindicates the name of the cluster to which the OBServer node belongs.Here is an example:
[root@xxx admin]#su - admin -bash-4.2$ mkdir -p /data/1/obdemo/{etc3,sort_dir,sstable,slog} -bash-4.2$ mkdir -p /data/log1/obdemo/{clog,etc2,ilog,oob_clog} -bash-4.2$ mkdir -p /home/admin/oceanbase/store/obdemo -bash-4.2$ for t in {etc3,sort_dir,sstable,slog};do ln -s /data/1/obdemo/$t /home/admin/oceanbase/store/obdemo/$t; done -bash-4.2$ for t in {clog,etc2,ilog,oob_clog};do ln -s /data/log1/obdemo/$t /home/admin/oceanbase/store/obdemo/$t; doneStart the observer process.
Run the following command to start the observer process:
[root@xxx admin]$ su - admin -bash-4.2$ cd /home/admin/oceanbase -bash-4.2$ ./bin/observer -I xx.xx.xx.xx -P XXXX -p YYYY -z zone1 -d /home/admin/oceanbase/store/obdemo -r 'xx.xx.xx.xx:xxxx:yyyy' -c 20190716 -n obdemo -o "system_memory=30GB,datafile_size=100G,config_additional_dir=/data/1/obdemo/etc3;/data/log1/obdemo/etc2"The parameters are described as follows:
-I: the IP address of the node to be started. In a multi-server deployment, the value of this parameter cannot be127.0.0.1.In the current version, you can still start a node by specifying the name of the network interface card (NIC) to be initialized (for example,
-i eth0). However, we recommend that you specify the IP address (for example,-I 10.10.10.1) to start a node. Additionally, you can specify both the IP address and the NIC name (for example,-I 10.10.10.1 -i eth0) to start a node. However, we recommend that you do not use this method.-c: the cluster ID. The value of this parameter can be obtained by using theSHOW PARAMETERS LIKE 'cluster_id';statement.-p: the SQL port number. The default value is 2881. We recommend that you do not modify this parameter unless there is a specific reason.-P: the RPC port number. The default value is 2882. We recommend that you do not modify this parameter unless there is a specific reason.-n: the cluster name. The value of this parameter can be obtained by using theSHOW PARAMETERS LIKE 'cluster';statement. In this example, the cluster name isobdemo.-z: the name of the zone to which the node belongs. You can query theDBA_OB_ZONESview for the zones in the cluster.-d: the data directory.-r: the RS address list of the OceanBase cluster.-l: the log level. In this example, the value isWARN, which means that only logs with the WARNING level and higher are output.For more information about the log levels in OceanBase Database, see Log levels.
-o: the startup configuration of the cluster. You need to configure this parameter based on the actual situation.When you use the
-oparameter, note that:The parameter name is case-insensitive. However, to avoid confusion, we recommend that you use the parameter names specified in
observer.config.bin.The parameter name must not contain the following special characters: spaces,
\r,\n, and\t.There must be an equal sign (=) between the parameter name and the parameter value.
The parameters are separated by commas (,).
In the command:
system_memory: the memory reserved for OceanBase Database. The default value is 30 GB.datafile_size: the size of the SSTable file in the data directory. The default value is estimated based on the available space of/data/1/. We recommend that you set the value to at least 100 GB to reserve some space.config_additional_dir: the redundant parameter file directory.
Here is an example:
[root@xxx admin]$ su - admin -bash-4.2$ cd /home/admin/oceanbase -bash-4.2$ ./bin/observer -I xx.xx.xx.1 -c 20221216 -p 2881 -P 2882 -z zone4 -n obdemo -d /home/admin/oceanbase/store/obdemo -r 'xx.xx.xx.1:2882:2881' -l WARN -o "system_memory=30GB,datafile_size=100G,config_additional_dir=/data/1/obdemo/etc3;/data/log1/obdemo/etc2"(Optional) If you want to add multiple nodes, repeat the steps from 2 to 5.
Add a node to the cluster.
Log in to the
systenant of the cluster as therootuser.Note that you must specify the corresponding parameters in the following sample code based on your actual database configurations.
obclient -h10.xx.xx.xx -P2883 -uroot@sys#obdemo -p***** -AFor more information about how to connect to a database, see Overview (MySQL mode) and Overview (Oracle mode).
Run the following command to add a node to a zone in the cluster.
ALTER SYSTEM ADD SERVER 'svr_ip:svr_port' [,'svr_ip:svr_port'...] [ZONE [=] 'zone_name'];The parameters are described as follows:
svr_ip: the IP address of the node to be added.svr_port: the RPC port number of the node. The default value is2882.zone_name: the name of the zone to which the node belongs.
Here is an example:
ALTER SYSTEM ADD SERVER '10.xx.xx.xx:2882','10.xx.xx.xx:2882' ZONE 'zone4';This operation adds the OBServer node to the service list. Only OBServer nodes in the service list can provide services.
After the operation succeeds, query the
DBA_OB_SERVERSview for confirmation.Here is an example:
SELECT * FROM oceanbase.DBA_OB_SERVERS;If the added OBServer node appears in the list, the addition was successful.
Next steps
Adding nodes is suitable for scenarios of elastic scaling up and deployment adjustment:
In an elastic scaling up scenario, after a node is added, there are more nodes in the zone to accommodate units. You can then migrate units, adjust the value of
UNIT_NUMfor a tenant, and create a new tenant. For more information, see the following topics:In a deployment adjustment scenario, including the adjustment from three IDCs in one region to five IDCs across three regions, or the migration of a zone from one data center to another during a data center shutdown. In this scenario, you must first add a zone and then add nodes in the zone. After that, you can modify the locality attribute of tenants. For more information, see Modify locality.
References
For more information about node O&M, see the following topics: