You can add a node to an OceanBase cluster for elastic scaling or deployment adjustment.
Elastic scaling scenario: After a zone has more nodes, you can migrate units to the zone and adjust the
UNIT_NUMof a tenant or create a new tenant.Deployment adjustment scenario: You can adjust the deployment of a cluster from three IDCs in the same region to five IDCs. In a scenario of data center shutdown, you can move a zone from the original data center to another one. To implement this, you must first add the zone and then add nodes to the zone and adjust the locality attribute of tenants.
The elastic scaling feature of OceanBase Database offers a clear architectural advantage over traditional databases. In a traditional database, data is stored on one server. OceanBase Database can distribute data to multiple servers to resolve the scalability issue 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 so that the cluster can accommodate more tenants, and each tenant can handle more data and business traffic. Conversely, when the capacity of a cluster or a tenant is excessive, you can remove some nodes to reduce costs.
The multi-replica deployment capability of OceanBase Database offers another architectural advantage over traditional databases. In OceanBase Database, data replicas are deployed across multiple servers. In this way, OceanBase Database achieves lossless disaster recovery at multiple levels, including lossless disaster recovery at the standalone server level, data center level, and region level. Additionally, OceanBase Database allows you to flexibly adjust the deployment architecture to align with technological advancements in your business.
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
(Optional) If you want to add a node and then add the node to a zone, make sure that the zone has been added. For more information, see Add a zone.
Use
sshto log in to the OBServer node that you want to add, initialize the OBServer node, and configure the clock source.For more information about how to initialize an OBServer node, see Initialize an OBServer node 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 that you want to add, and install the RPM package of OceanBase Database.Before you add a node, you must install the database software on all OBServer nodes that you want to add.
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; and$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 between the data directory and 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.
Execute 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,127.0.0.1cannot be specified as the target IP address.In the current version, you can still start a node by specifying the name of the network interface card (NIC) as the parameter value of
-i. However, we recommend that you specify the IP address (for example,-I 10.10.10.1) instead. 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, but we do not recommend that you specify both parameters.-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 do not recommend that you modify this parameter unless there is a clear reason.-P: the RPC port number. The default value is 2882. We do not recommend that you modify this parameter unless there is a clear 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 a cluster.-d: the data directory.-r: the list of RS addresses of the OceanBase cluster.-l: the log level. In this example, the log level is set toWARN, which means that only logs with the WARNING level and above are output.For more information about 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,\tThere must be an equal sign (=) between the parameter name and the parameter value.
The parameters are separated by commas (,).
In this case:
system_memory: the memory reserved for OceanBase Database. The default value is 30 GiB.datafile_size: the size of the SSTable file in the data directory. The value is estimated based on the available space in/data/1/. We recommend that you set the value to at least 100 GiB and reserve some space.config_additional_dir: the redundant directory for storing parameter files.
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).
Execute 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 of a query statement:
SELECT * FROM oceanbase.DBA_OB_SERVERS;If the OBServer node that you added is listed in the result, the addition is successful.
Next steps
Adding nodes is suitable for scenarios of elastic scaling up and deployment adjustment:
In an elastic scaling up scenario, after adding nodes, the zone where the nodes reside can accommodate more units. This enables you to perform subsequent operations such as migrating units, adjusting the
UNIT_NUMof a tenant, and creating a new tenant. For more information, see the following topics:Adjust deployment scenarios: Adjust deployment scenarios, including changing the cluster deployment method 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 decommissioning. This scenario requires first adding a Zone, then adding nodes within that Zone, and subsequently adjusting the Locality attributes of the tenant. For related operations on modifying tenant Locality attributes, see Modify Locality.
References
For more information about node O&M, see the following topics: