You can add nodes to an OceanBase cluster for 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 deployment scenarios: Adjust deployment scenarios, including changing the cluster deployment method from three data centers in the same city to five data centers in three regions, and relocating Zones from one data center to another in the scenario of data center closure. This scenario requires adding a Zone first, then adding nodes within that Zone, and finally adjusting the Locatity attribute of the tenant.
The elasticity of OceanBase Database is a significant advantage over traditional databases. In a traditional database, data is stored on one server. OceanBase Database can distribute data across 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, if the capacity of a cluster or a tenant is excessive, you can remove some nodes to reduce costs.
The multi-replica deployment capability is another significant advantage of OceanBase Database over traditional databases. In OceanBase Database, multiple replicas of data can be deployed in different servers. This provides the foundation for various lossless disaster recovery scenarios, including lossless disaster recovery at the standalone level, data center level, and region level. Additionally, OceanBase Database allows you to flexibly adjust the deployment architecture of a cluster to accommodate 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 up a cluster section in the obd documentation.
(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 that you want to add, 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 that you want to add, 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 an independent 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.
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,127.0.0.1cannot be specified as the target IP address.You can still start a node by specifying the name of the network interface card (NIC) in this version. 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.In this version, you can specify an IPv6 address to identify the node. Note that:
- An IPv6 address can be a global address or a link address. We recommend that you use a global address.
- Before you specify the
-Ioption, you must add the-6option.
-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 clear reason.-P: the RPC port number. The default value is 2882. We recommend that you do not 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 zone to which the node belongs. You can query theDBA_OB_ZONESview for the zones in the cluster.-d: the data directory.-r: the list of RS addresses of the OceanBase cluster.If you specify an IPv6 address, note that:
- An IPv6 address can be a global address or a link address. We recommend that you use a global address.
- You must wrap the IP address in
[]. - Before you specify the
-roption, you must add the-6option.
-l: the log level. In this example, the log level is set toWARN, which means that only messages with the WARNING level and higher will be logged.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.To use the
-ooption, you must meet the following requirements:The option is case-insensitive. However, we recommend that you specify the option in the same way as it appears in the
observer.config.binfile.The option name must not contain spaces or the following special characters:
\r,\n,\tThe option name and option value must be separated by an equal sign (
=).The options must be separated by commas (
,).
In this option, you can specify the following parameters:
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 obtained by estimating the available space in/data/1/. We recommend that you specify a value that is not less than 100 GB while reserving some space as the remaining space.config_additional_dir: the redundant directory for 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"An example of starting the node with an IPv6 address is as follows:
[root@xxx admin]$ su - admin -bash-4.2$ cd /home/admin/oceanbase -bash-4.2$ ./bin/observer -6 -I xxxx:xxxx:xxxx:xxxx:xxx:xxxx:xxxx:ebd8 -c 20221216 -p 2881 -P 2882 -z zone4 -n obdemo -d /home/admin/oceanbase/store/obdemo -r '[xxxx:xxxx:xxxx:xxxx:xxx:xxxx:xxxx:ebd8]: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).
Run 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 query result includes the OBServer node that you added, the addition was successful.
Next steps
Adding a node is useful for elastic scaling and deployment adjustment:
In an elastic scaling 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, you can adjust the deployment of a cluster from three IDCs in the same region to five IDCs across three regions, or from one data center to another data center in the same region. To perform a migration between regions, you must first add a zone and then add nodes to 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:
