You can add a node to an OceanBase cluster for either scaling up or re-deployment.
Scaling up: 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 to 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 closures. This scenario requires first adding a Zone, then adding nodes within that Zone, and subsequently adjusting the Locality attributes of the tenant.
The elasticity of OceanBase Database offers a clear architectural advantage over traditional databases. In a traditional database, all data is stored on one server. OceanBase Database can distribute data across multiple servers to address the limitations on scalability and to 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, and to enable the tenants to store more data and handle more 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 clear architectural advantage over traditional databases. In a traditional database, if the primary server fails, the database will be unavailable until a new primary server is manually designated. OceanBase Database can distribute replicas of data across multiple servers to provide lossless disaster recovery at the standalone server level, Internet data center level, and region level. Additionally, OceanBase Database allows flexible adjustment of its deployment architecture to adapt to technological advancements and business growth.
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
If you want to add nodes to an OceanBase cluster in OceanBase Database Community Edition, see Add a node in obd.
(Optional) If you want to add a zone and then add nodes to the zone, make sure that the zone has been added. For more information, see Add a zone.
Log in to the OBServer node to be added via
ssh, initialize the OBServer node, and configure the clock source.For more information about how to initialize the 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.
Log in to the OBServer node to be added via
ssh, 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.
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: specifies the IP address of the node to be started. In a multi-server deployment,127.0.0.1cannot be used as the target IP address.You can still start a node by specifying the network interface name (for example,
-i eth0) in the current version. However, it is recommended 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 network interface name (for example,-I 10.10.10.1 -i eth0) to start a node. However, this method is not recommended.In the current version, you can specify an IPv6 address to identify the node. Note the following points when you specify an IPv6 address:
- An IPv6 address can be a global address or a link address. We recommend that you use a global address.
- The
-6option must be added before the-Ioption.
-c: specifies the cluster ID. The value of this option can be obtained by using theSHOW PARAMETERS LIKE 'cluster_id';statement.-p: specifies the SQL port number. The default value is 2881. We recommend that you do not modify the default value unless there is a specific reason.-P: specifies the RPC port number. The default value is 2882. We recommend that you do not modify the default value unless there is a specific reason.-n: specifies the cluster name. The value of this option can be obtained by using theSHOW PARAMETERS LIKE 'cluster';statement. In this example, the cluster name isobdemo.-z: specifies the zone to which the node belongs. You can query theDBA_OB_ZONESview for the zones in the cluster.-d: specifies the data directory.-r: specifies the RS address list of the OceanBase cluster.If you specify an IPv6 address, note the following points:
- An IPv6 address can be a global address or a link address. We recommend that you use a global address.
- The IPv6 address must be enclosed in
[]. - The
-6option must be added before the-roption.
-l: specifies 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 log levels in OceanBase Database, see Log levels.
-o: specifies 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 name is case-insensitive. However, it is recommended that you use the option name as it appears in
observer.config.bin.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 the statement:
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 set the value to at least 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).
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 will add 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 appears in the result list, the addition is successful.
Next steps
Adding a node is suitable for elastic scaling and deployment adjustment scenarios:
In an elastic scaling scenario, after a node is added, the zone where the node resides has more nodes to accommodate units. This enables you to perform subsequent operations such as migrating units, adjusting the
UNIT_NUMof a tenant, and creating a tenant. For more information, see the following topics:In a deployment adjustment scenario, you can adjust the deployment of a cluster by converting a multi-region IDC deployment to a multi-zone IDC deployment or migrating zones from one data center to another in response to a data center shutdown. To perform a zone migration, first add the zones, then add nodes to the zones, and finally 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: