You can add a node to an OceanBase cluster for elastic scaling or deployment adjustment.
Elastic scaling: After you scale out a cluster, more nodes are available in the zone to accommodate resource units. Then, you can perform a series of operations, such as migrating a unit, modifying the
UNIT_NUMparameter for a tenant, and creating a tenant.Deployment adjustment: You can adjust the deployment mode of a cluster from three IDCs in the same region to five IDCs across three regions, and migrate a zone from one IDC to another when an IDC is to be demolished. In this scenario, you must first add a zone, add nodes to the zone, and then modify the locality of the tenant.
OceanBase Database outperforms conventional databases in scaling due to its distributed architecture. A conventional database stores its data on a single server, but OceanBase Database scatters its data on different servers, enhancing scalability. When the capacity of a cluster or tenant is insufficient, you only need to add more nodes. In this way, the cluster can accommodate more tenants and each tenant can accommodate more data and business traffic. When the capacity of a cluster or tenant is in surplus, you can remove nodes to reduce the cost.
The capability to deploy multiple replicas is also an architectural advantage of OceanBase Database compared with conventional databases. This capability forms the foundation of OceanBase Database's fault tolerance feature in different levels, including the server level, IDC level, and region level. Additionally, OceanBase Database allows you to flexibly adjust the cluster deployment architecture to adapt to the technological evolution of various business scenarios.
Prerequisites
All OBServer nodes to be added have been configured. For more information, see Before deployment.
OceanBase Database is installed on all OBServer nodes to be added. You can download the installation package from the Download Center or request the installation package from OceanBase Technical Support.
Procedure
Note
This section mainly introduces how to manually add nodes to the cluster through commands. For OceanBase Database Community Edition, if you need to add nodes to the OceanBase cluster through obd, see Scale out a cluster and change cluster components.
(Optional) In the case where you must first add a zone before you can add nodes to the zone, make sure that the zone has been added. For information about how to add a zone, see Add a zone.
SSH to an OBServer node to be added, initialize the OBServer node, and configure the clock source.
For information about how to initialize an OBServer node, see Initialize an OBServer node by using oatcli.
For information about how to configure the clock source, see Configure the clock source.
Install the RPM package of OceanBase Database.
Before you add OBServer nodes, you must install the OceanBase Database software on these OBServer nodes.
The commands are as follows:
[root@xxx /]#cd $rpm_dir [root@xxx $rpm_dir]#rpm -ivh $rpm_nameHere,
rpm_dirspecifies the directory that stores the RPM package, and$rpm_namespecifies the name of the RPM package.Initialize the directories of OceanBase Database.
We recommend that you set the data directory of OceanBase Database on an independent disk and link this directory to the
homedirectory of OceanBase Database by using a soft link.[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_namespecifies the name of the cluster to which the OBServer node is to be added.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 on the node.
Run the following command to start the observer process:
[root@xxx admin]$ su - admin -bash-4.2$ /home/admin/oceanbase/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"where
-Ispecifies the IP address of the node to be started. If OceanBase Database is deployed in distributed mode, you cannot specify127.0.0.1for this option.In the current OceanBase Database version, you can still specify the NIC name to start a node, such as
-i eth0. However, we recommend that you specify the IP address to start a node, such as-I 10.10.10.1. You can also specify both the IP address and the NIC name to start a node, such as-I 10.10.10.1 -i eth0. However, this is not recommended.In the current version, you can specify an IPv6 address for a node. If you do so, note that:
- IPv6 addresses are classified into global addresses and link addresses. We recommend that you use a global address.
- You need to add
-6prior to the-Iparameter.
-cspecifies the cluster ID. You can execute theSHOW PARAMETERS LIKE 'cluster_id';statement to obtain the cluster ID.-pspecifies the SQL port number, which is generally 2881. We recommend that you do not modify the SQL port number unless necessary.-Pspecifies the RPC port number, which is generally 2882. We recommend that you do not modify the SQL port number unless necessary.-nspecifies the name of the cluster. You can obtain the cluster name by using theSHOW PARAMETERS LIKE 'cluster';statement. In this example, the cluster name isobdemo.-zspecifies the zone to which the OBServer node is to be added. You can query theDBA_OB_ZONESview for the names of zones in a cluster.-dspecifies the data directory.-rspecifies the RootService address list of the OceanBase cluster to which the OBServer node is to be added.If you specify IPv6 addresses, note that:
- IPv6 addresses are classified into global addresses and link addresses. We recommend that you use a global address.
- An IP address must be enclosed with square brackets (
[ ]). - You need to add
-6prior to the-rparameter.
-lspecifies the level of logs to be printed. The value isWARNin this example, indicating that logs of the WARNING level are to be printed.For more information about the log levels in OceanBase Database, see Log levels.
-ospecifies the startup parameters of the cluster, which must be configured based on the actual situation.When the
-ooption is used, note that:The parameters are case-insensitive. However, we recommend that you set them based on the names in
observer.config.bin.A parameter name cannot contain the following special characters: spaces,
\r,\n, and\t.An equal sign (=) is required between the name and the value of a parameter.
Separate the parameters with commas (,).
Parameters in the
-ooption are described as follows:system_memory: the size of the internal reserved memory of OceanBase Database, which is 30 GB by default.datafile_size: the size of SSTable files (initialized at a time) in OceanBase Database. This value is estimated based on the available space of/data/1/. We recommend that you specify the value to at least 100 GB and keep some reserved space.config_additional_dir: the redundancy directory for parameter files.
Here is an example:
[root@xxx admin]$ su - admin -bash-4.2$ /home/admin/oceanbase/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"Here is an example of starting the observer process on a node with an IPv6 address:
[root@xxx admin]$ su - admin -bash-4.2$ /home/admin/oceanbase/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) To add more OBServer nodes, repeat steps 2 to 5.
Add the 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 Connection methods (MySQL mode) or Connection methods (Oracle mode).
Execute the following statement to add the node to a zone of the cluster:
ALTER SYSTEM ADD SERVER 'svr_ip:svr_port' [,'svr_ip:svr_port'...] [ZONE [=] 'zone_name'];where
svr_ipspecifies the IP address of the node to be added.svr_portspecifies the RPC port of the node to be added. The default value is2882.zone_namespecifies the name of the zone to which the node is to be added.
Here is an example:
ALTER SYSTEM ADD SERVER '10.xx.xx.xx:2882','10.xx.xx.xx:2882' ZONE 'zone4';This statement adds the OBServer node to the service list. Only OBServer nodes in the service list can provide services.
After the statement is executed, you can query the
DBA_OB_SERVERSview to verify whether the node is added.Here is an example:
SELECT * FROM oceanbase.DBA_OB_SERVERS;If the OBServer node appears in the list, it is successfully added.
What to do next
You can add nodes for elastic scaling or deployment adjustment.
Elastic scaling: After a node is added, more nodes are available in the zone to accommodate resource units. Then, you can perform a series of operations, such as migrating a unit, modifying the
UNIT_NUMparameter for a tenant, and creating a tenant. For more information, see the following topics:Deployment adjustment: You can adjust the deployment mode of a cluster from three IDCs in the same region to five IDCs across three regions, and migrate a zone from one IDC to another when an IDC is to be demolished. In this scenario, you must first add a zone, add nodes to the zone, and then modify the locality of the tenant. For more information about how to modify the locality of a tenant, see Modify locality.
References
For more node-related O&M operations, see the following topics: