OceanBase Database is built based on an integrated architecture for centralized and distributed modes and supports the online upgrade from standalone deployment to distributed deployment.
This topic describes how to upgrade to three-replica deployment online by using an RPM package.
Note
- You can also switch from a standalone deployment to a distributed deployment by adding OBServer nodes to the zone, which is a deployment mode with single-replica and multiple nodes. For more information, see Add a node.
- If you are using OBD to deploy an OceanBase cluster, you can also use OBD to scale the cluster.
Prerequisites
The servers have been configured. For more information, see Configure servers.
The servers have been initialized. For more information about how to initialize a server, see Initialize an OBServer node by using oatcli.
You have obtained the RPM package of OceanBase Database.
Note
To download the required package, go to OceanBase Download Center and then find the installation package of the required version. If no installation package is available, contact OceanBase Technical Support.
Procedure
Step 1: Deploy OBServer nodes
Perform the following steps on two servers.
Install the RPM package for OceanBase Database.
Here is an example:
[root@xxx /home/admin/rpm]# rpm -ivh oceanbase-4.1.0.0-100000682023020119.el7.x86_64.rpm Preparing... ################################# [100%] Updating / installing... 1:oceanbase-4.1.0.0-100000682023020################################# [100%](Optional) Clear the OceanBase Database directory.
You do not need to clear the directory if you deploy OceanBase Database on the server for the first time.
You can directly clear the old OceanBase Database directory in the following cases:
- You want to clear the old OceanBase Database environment.
- Problems occur during the installation and deployment process of OceanBase Database. The installation environment becomes disordered or files that will affect the next installation are generated.
Here is an example:
[root@xxx /home/admin]# rm -rf /data/1/obdemo [root@xxx /home/admin]# rm -rf /data/log1/obdemo [root@xxx /home/admin]# rm -rf /home/admin/oceanbase/store/obdemo [root@xxx /home/admin]# rm -rf /home/admin/oceanbase/log/* /home/admin/oceanbase/etc/*config*Initialize the OceanBase Database directory.
We recommend that you specify the data directory of OceanBase Database to an independent disk and link this directory to the home directory of OceanBase Database by using a soft link.
Here is an example:
[root@xxx /home/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; doneNote
The
obdemodirectory is named after the cluster and can be modified. It is required when the process starts.Start the observer process.
Start the observer process as the
adminuser by executing the following statement:/home/admin/oceanbase/bin/observer {-I $ip | -i $devname} -P $rpc_port -p $sql_port -z $zone_name -d /home/admin/oceanbase/store/$cluster_name -r '$ip:2882:2881' -c $cluster_id -n $cluster_name -o "system_memory=30G,datafile_size=100G,config_additional_dir=/data/1/$cluster_name/etc3;/data/log1/$cluster_name/etc2"Options in the command above are described as follows:
Option Description -I|-i-I: the IP address of the node to be started. In multi-node deployment, you cannot use 127.0.0.1 as the destination IP address. We recommend that you use an IP address such as-I 10.10.10.1, to start a node.-i: the NIC name. You can use theifconfigcommand to view the NIC name.
Note
OceanBase Database allows you to start a node by specifying both the IP address and the NIC. For example,
-I 10.10.10.1 -i eth0. However, we recommend that you do not use this method.-pThe service port number, which is usually set to 2881.-PThe RPC port number, which is usually set to 2882.-nThe name of the cluster. It can be modified. Cluster names must be unique. -zThe zone where the started observer process belongs. -dThe primary directory of the cluster, which is created during initialization. Do not modify fields other than $cluster_name.-cThe cluster ID. It is a group of digits and can be modified. Cluster IDs must be unique. -lThe log level. -rThe RootService list in the format of $ip:2882:2881. Multiple items are separated with semicolons (;) to indicate RootService information.-oThe cluster startup parameters that need to be specified as needed. system_memoryspecifies the internal reserved memory of OceanBase Database, which is30Gby default. You can adjust this parameter to a smaller value in the case of insufficient memory on the server. The impact is that memory may be insufficient during performance tests.datafile_sizespecifies the size of theSSTabledata file of OceanBase Database, which is determined based on the available space of/data/1/. You no longer need to specify the size again once specified in this step. We recommend that you specify the data file size to at least100Gand reserve some spaces.Note
If
/data/1and/data/log1belong to the same file system (share the same disk), make sure that the space reserved for/data/log1is two to four times the size of the memory.config_additional_dirspecifies the redundancy directory for the parameter file.
Here are some examples:
Start the observer process on the server whose IP address is
10.10.10.2.[root@xxx /home/admin]# su - admin -bash-4.2$ /home/admin/oceanbase/bin/observer -I 10.10.10.2 -P 2882 -p 2881 -z zone2 -d /home/admin/oceanbase/store/obdemo -r '10.10.10.2:2882:2881' -c 10001 -n obdemo -o "system_memory=30G,datafile_size=500G,config_additional_dir=/data/1/obdemo/etc3;/data/log1/obdemo/etc2"Start the observer process on the server whose IP address is
10.10.10.3.[root@xxx /home/admin]# su - admin -bash-4.2$ /home/admin/oceanbase/bin/observer -I 10.10.10.3 -P 2882 -p 2881 -z zone3 -d /home/admin/oceanbase/store/obdemo -r '10.10.10.3:2882:2881' -c 10001 -n obdemo -o "system_memory=30G,datafile_size=500G,config_additional_dir=/data/1/obdemo/etc3;/data/log1/obdemo/etc2"
Verify whether the observer process is started.
You can use the following commands to check whether the observer process has started successfully:
- Run the
netstat -ntlpcommand. If ports2881and2882are listened to, the observer process is started. - Run the
ps -ef|grep observercommand to return information about the observer process.
Here is an example:
-bash-4.2$ netstat -ntlp (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:2881 0.0.0.0:* LISTEN 115745/observer tcp 0 0 0.0.0.0:2882 0.0.0.0:* LISTEN 115745/observer ... ... ... ... ... ... -bash-4.2$ ps -ef|grep observer admin 115745 0 37 17:14 ? 00:00:37 /home/admin/oceanbase/bin/observer -I 10.10.10.3 -P 2882 -p 2881 -z zone3 -d /home/admin/oceanbase/store/obdemo -r 10.10.10.3:2882:2881 -c 10001 -n obdemo -o system_memory=30G,datafile_size=100G,config_additional_dir=/data/1/obdemo/etc3;/data/log1/obdemo/etc2- Run the
Step 2: Scale out the cluster
Log on to the
systenant of the cluster as therootuser.[root@xxx /home/admin]# obclient -h10.10.10.1 -P2881 -uroot@sys -p Enter password: Welcome to the OceanBase. Commands end with ; or \g. Your OceanBase connection id is 3221490218 Server version: OceanBase 4.1.0.0 (r100000682023020119-c760cbb1023d73a2647f28add283646b1569418f) (Built Feb 1 2023 20:07:36) Copyright (c) 2000, 2018, OceanBase and/or its affiliates. All rights reserved. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. obclient [(none)]>Add zones to the cluster.
Add two zones named
zone2andzone3. Here is an example:obclient [(none)]> ALTER SYSTEM ADD ZONE zone2; Query OK, 0 rows affected obclient [(none)]> ALTER SYSTEM ADD ZONE zone3; Query OK, 0 rows affectedStart
zone2andzone3.Here is an example:
obclient [(none)]> ALTER SYSTEM START ZONE zone2; Query OK, 0 rows affected obclient [(none)]> ALTER SYSTEM START ZONE zone3; Query OK, 0 rows affectedAdd OBServer nodes to the cluster.
Add two OBServer nodes deployed in Step 1 to
zone2andzone3, respectively.Here is an example:
obclient [(none)]> ALTER SYSTEM ADD SERVER '10.10.10.2:2882' ZONE 'zone2'; Query OK, 0 rows affected obclient [(none)]> ALTER SYSTEM ADD SERVER '10.10.10.3:2882' ZONE 'zone3'; Query OK, 0 rows affectedVerify whether the OBServer nodes are successfully added.
Execute the following statement to verify whether the added OBServer nodes are in the list. If yes, the OBServer nodes are successfully added.
obclient [(none)]> SELECT SVR_IP,SVR_PORT,ID,ZONE,SQL_PORT,STATUS,START_SERVICE_TIME FROM oceanbase.DBA_OB_SERVERS; +------------+----------+----+-------+----------+--------+----------------------------+ | SVR_IP | SVR_PORT | ID | ZONE | SQL_PORT | STATUS | START_SERVICE_TIME | +------------+----------+----+-------+----------+--------+----------------------------+ | 10.10.10.3 | 2882 | 3 | zone3 | 2881 | ACTIVE | 2023-03-03 17:26:44.207835 | | 10.10.10.2 | 2882 | 2 | zone2 | 2881 | ACTIVE | 2023-03-03 17:25:47.772032 | | 10.10.10.1 | 2882 | 1 | zone1 | 2881 | ACTIVE | 2023-03-03 10:09:27.040795 | +------------+----------+----+-------+----------+--------+----------------------------+ 3 rows in set
Step 3: Add replicas to the tenant
Log on to the
systenant of the cluster as therootuser.[root@xxx /home/admin]# obclient -h10.10.10.1 -P2881 -uroot@sys -p Enter password: Welcome to the OceanBase. Commands end with ; or \g. Your OceanBase connection id is 3221490218 Server version: OceanBase 4.1.0.0 (r100000682023020119-c760cbb1023d73a2647f28add283646b1569418f) (Built Feb 1 2023 20:07:36) Copyright (c) 2000, 2018, OceanBase and/or its affiliates. All rights reserved. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. obclient [(none)]>Modify
ZONE_LISTof the resource pool.Add the new zones to the resource pool of the tenant. Here is an example:
obclient [(none)]> ALTER RESOURCE POOL pool001 ZONE_LIST=('zone1','zone2','zone3'); Query OK, 0 rows affectedAdd a replica to a tenant.
Note
If you add replicas to a tenant by modifying the locality, you must add them one by one.
obclient [(none)]> ALTER TENANT tenant_oracle001 LOCALITY='F@zone1,F@zone2'; Query OK, 0 rows affected obclient [(none)]> ALTER TENANT tenant_oracle001 LOCALITY='F@zone1,F@zone2,F@zone3'; Query OK, 0 rows affected