You can add a node to an OceanBase cluster for either elastic scaling or deployment adjustment.
Elastic scaling: After the addition, there are more nodes within a zone to accommodate units. This enables you to migrate units and adjust the values of
UNIT_NUMfor tenants and create new tenants.Adjust the deployment scenario: Adjust the deployment scenario, including changing the cluster's 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 decommissioning. This scenario requires first adding a Zone, then adding nodes within that Zone, and subsequently adjusting the Locality attributes of the tenant.
The architecture of OceanBase Database offers clear advantages for elastic scaling compared with 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 a distributed architecture. When the capacity of a cluster or a tenant is insufficient, you can add more nodes to the cluster so that it can accommodate more tenants, and the tenants can store more data and handle more business traffic. Conversely, when the capacity of a cluster or a tenant is excessive, you can remove nodes from the cluster to reduce costs.
OceanBase Database's multi-replica deployment capability also offers clear advantages over traditional databases. With this capability, OceanBase Database can provide lossless disaster recovery at the node, Internet data center (IDC), and region levels, namely, lossless disaster recovery at multiple levels. In addition, OceanBase Database allows you to flexibly adjust its 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
Note
This section describes how to manually add a node to a cluster by using commands. If you use OceanBase Database Community Edition, and want to add a node to an OceanBase cluster by using obd, refer to obd documentation for more information about cluster scaling up.
(Optional) If you want to add a node to a zone that has been created, 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 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, the value of this parameter cannot be127.0.0.1.You can still start a node by specifying the network card name (for example,
-i eth0) in this version. 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 network card name (for example,-I 10.10.10.1 -i eth0) to start a node, but we do not recommend that you do so.-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 the default value unless there is a clear reason.-P: the RPC port number. The default value is 2882. We recommend that you do not modify the default value 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 zone to which the node belongs. You can query theDBA_OB_ZONESview for the zone names 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 of the WARNING level and those with higher severity are displayed.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 defined 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 GB.datafile_size: the size of the SSTable file in OceanBase Database. The value is estimated based on the available space in/data/1/. We recommend that you set the value to at least 100 GB and keep some space for remaining data.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 steps 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 of 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 you added appears in the query result, the addition was successful.
Next steps
Adding nodes is suitable for elastic scaling and deployment adjustment scenarios:
In an elastic scaling scenario, after you add nodes, 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, you can adjust the deployment of a cluster from three IDCs in one region to five IDCs across three regions, or from one region to another. To perform a zone migration in a data center withdrawal scenario, you must first add a zone and then add nodes in the zone. After that, you can modify the locality attribute of the tenant. For more information, see Modify locality.
References
For more information about node O&M, see the following topics: