OceanBase Database supports single-replica deployment, and a single-replica OceanBase cluster can be scaled out by adding nodes. Therefore, it is also called a cluster.
This topic describes how to deploy a single-replica OceanBase cluster by using the CLI.
Prerequisites
Before you install OceanBase Database, make sure that:
- The OBServer node has been configured. For more information, see Configure servers and Initialize an OBServer node by using oatcli.
- The
adminuser has been created on the OBServer node. - You have obtained the RPM package of OceanBase Database. For more information, see Prepare installation packages.
Procedure
Step 1: Install the RPM package
Install the RPM package for OceanBase Database.
Here,
$rpm_dirspecifies the directory in which the RPM package is stored, and$rpm_namespecifies the name of the RPM package.[root@xxx /]# cd $rpm_dir [root@xxx $rpm_dir]# rpm -ivh $rpm_nameNote
The OceanBase Database software will be installed under the
/home/admin/oceanbasedirectory.Here is an example:
[root@xxx /home/admin/rpm]# rpm -ivh oceanbase-4.2.0.0-100000052023073123.el7.x86_64.rpm Preparing... ################################# [100%] Updating / installing... 1:oceanbase-4.2.0.0-100000052023073################################# [100%]Install OceanBase Client (OBClient).
OceanBase Database instances are compatible with Oracle and MySQL. To connect an Oracle tenant to a Java program, the Java driver file (
oceanbase-client-*.jar) provided by OceanBase Database is required. To access an Oracle tenant by using the CLI, you also need to install OBClient.OBClient is a CLI client of OceanBase Database. By using OBClient, you can access MySQL and Oracle tenants of OceanBase Database.
Here is an example:
[root@xxx $rpm_dir]# rpm -ivh obclient-1.2.6-20210510164331.el7.alios7.x86_64.rpm ## Verify that the installation is successful. ## [root@xxx $rpm_dir]# which obclient /usr/bin/obclient
Step 2: Configure directories
Clear the OceanBase Database directory (not required at the first deployment).
If you want to clear the old OceanBase Database environment, or problems occur during the installation and deployment process of OceanBase Database and thereby cause an environmental disorder or generate files that will affect the next installation, you can directly clear the old OceanBase Database directory. In the following context,
$cluster_namespecifies the cluster name.[root@xxx admin]# su - admin -bash-4.2$ kill -9 `pidof observer` -bash-4.2$ rm -rf /data/1/$cluster_name -bash-4.2$ rm -rf /data/log1/$cluster_name -bash-4.2$ rm -rf /home/admin/oceanbase/store/$cluster_name /home/admin/oceanbase/log/* /home/admin/oceanbase/etc/*config* -bash-4.2$ ps -ef|grep observerHere is an example:
[root@xxx admin]# su - admin -bash-4.2$ kill -9 `pidof observer` -bash-4.2$ rm -rf /data/1/obdemo -bash-4.2$ rm -rf /data/log1/obdemo -bash-4.2$ rm -rf /home/admin/oceanbase/store/obdemo /home/admin/oceanbase/log/* /home/admin/oceanbase/etc/*config* -bash-4.2$ ps -ef|grep observerInitialize the OceanBase Database directory.
We recommend that you store the data directory of OceanBase Database on an independent disk and link this directory to the software home directory by using a soft link. In the following context,
$cluster_namespecifies the cluster name.Note
OceanBase Database supports an independent
slogdisk, so thatslogfiles do not need to share a disk with data files.slogfiles andclogfiles can share an SSD. For more information about the installation directory of OceanBase Database, see Structure of the OBServer node installation directory.[root@xxx admin]# su - admin -bash-4.2$ mkdir -p /data/1/$cluster_name/{etc3,sstable,slog} -bash-4.2$ mkdir -p /data/log1/$cluster_name/{clog,etc2} -bash-4.2$ mkdir -p /home/admin/oceanbase/store/$cluster_name -bash-4.2$ for t in {etc3,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};do ln -s /data/log1/$cluster_name/$t /home/admin/oceanbase/store/$cluster_name/$t; doneHere is an example:
[root@xxx admin]# su - admin -bash-4.2$ mkdir -p /data/1/obdemo/{etc3,sstable,slog} -bash-4.2$ mkdir -p /data/log1/obdemo/{clog,etc2} -bash-4.2$ mkdir -p /home/admin/oceanbase/store/obdemo -bash-4.2$ for t in {etc3,sstable,slog};do ln -s /data/1/obdemo/$t /home/admin/oceanbase/store/obdemo/$t; done -bash-4.2$ for t in {clog,etc2};do ln -s /data/log1/obdemo/$t /home/admin/oceanbase/store/obdemo/$t; doneNote
The
obdemodirectory is named after the cluster and can be customized. It is required when the process starts.The result is as follows:
-bash-4.2$ cd /home/admin/oceanbase -bash-4.2$ tree store/ store/ `-- obdemo |-- clog -> /data/log1/obdemo/clog |-- etc2 -> /data/log1/obdemo/etc2 |-- etc3 -> /data/1/obdemo/etc3 |-- slog -> /data/1/obdemo/slog `-- sstable -> /data/1/obdemo/sstable 6 directories, 0 files
Step 3: Initialize the OceanBase cluster
Note
The IP addresses in the sample code are masked, which is not an installation requirement. You need to enter the actual IP address of your server during deployment.
Start the observer process.
Notice
You must start the observer process as the
adminuser.OceanBase Database allows you to start the observer process on a server with a specified IPv4 or IPv6 address.
Start the observer process by using IPv4:
cd /home/admin/oceanbase && /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=500G,config_additional_dir=/data/1/$cluster_name/etc3;/data/log1/$cluster_name/etc2"Start the observer process by using IPv6:
cd /home/admin/oceanbase && /home/admin/oceanbase/bin/observer -6 {-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=500G,config_additional_dir=/data/1/$cluster_name/etc3;/data/log1/$cluster_name/etc2"Parameter description:
ParameterDescription-6Required when you start the observer process by using IPv6. -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.1to 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 name. 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 customized. Cluster names must be unique. -zThe zone to which the started observer process belongs. -dThe primary directory of the cluster, which is created when you initialize the directory. Do not modify fields other than $cluster_name.-cThe cluster ID. It is a group of digits and can be customized. Cluster IDs must be unique. -lThe log level. -rThe RootService list in the format of $ip:2882:2881. Multiple items are separated with semicolons (;), indicating the RootService information.Notice
When you start the observer process by using IPv6, the IP address must be enclosed in brackets (
[]).-oOptional. The cluster startup parameters. You can specify values for multiple parameters and separate the settings of different parameters with commas (,). We recommend that you set appropriate values for cluster startup parameters to optimize cluster performance and resource utilization. Here are some commonly used cluster startup parameters: - cpu_count: the total number of system CPU cores.
- system_memory: the memory reserved for the tenant whose ID is
500, that is, the internal reserved memory of OceanBase Database. If the machine has a small memory size, you can set this parameter to a smaller value. However, insufficient memory may occur during performance testing. - memory_limit: the total memory size available.
- datafile_size: the size of disk space available for data files. That is, the size of the data file
sstable(for one-time initialization) in OceanBase Database. You can evaluate the value of this parameter based on the available space on/data/1/. We recommend that the value is no less than100G. - datafile_disk_percentage: the percentage of total disk space allowed for data files.
- datafile_next: the step size of automatic scale-out for disk files.
- datafile_maxsize: the maximum size of disk space allowed for automatic scale-out of data files.
- config_additional_dir: the local directories for storing multiple copies of configuration files for redundancy.
- log_disk_size: the size of the log disk where REDO logs are stored.
- log_disk_percentage: the percentage of total disk space occupied by REDO logs.
- syslog_level: the level of system logs.
- syslog_io_bandwidth_limit: the maximum I/O bandwidth available for system logs. If this value is reached, the remaining system logs are discarded.
- max_syslog_file_count: the maximum number of log files that can be retained.
- enable_syslog_recycle: specifies whether to enable the switch for recording old logs before the OBServer node starts. It works in conjunction with
max_syslog_file_countto determine whether the log recycling logic takes old log files into account.
datafile_size,datafile_disk_percentage,datafile_next, anddatafile_maxsizetogether to achieve automatic scale-out of disk space for data files. For more information, see Configure automatic scale-out of disk space for data files. For more information about cluster configuration, see Cluster-level parameters.Example of starting the observer process by using IPv4:
[root@xxx /home/admin]# su - admin -bash-4.2$ cd /home/admin/oceanbase && /home/admin/oceanbase/bin/observer -I 10.10.10.1 -P 2882 -p 2881 -z zone1 -d /home/admin/oceanbase/store/obdemo -r '10.10.10.1:2882:2881' -c 10001 -n obdemo -o "system_memory=30G,datafile_size=500G,config_additional_dir=/data/1/obdemo/etc3;/data/log1/obdemo/etc2"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 successfully. - 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 11111/observer tcp 0 0 0.0.0.0:2882 0.0.0.0:* LISTEN 11111/observer ... ... ... ... ... ... -bash-4.2$ ps -ef|grep observer admin 11111 0 43 17:58 ? 00:00:14 /home/admin/oceanbase/bin/observer -I 10.10.10.1 -P 2882 -p 2881 -z zone1 -d /home/admin/oceanbase/store/obdemo -r 10.10.10.1:2882:2881 -c 10001 -n obdemo -o system_memory=30G,datafile_size=500G,config_additional_dir=/data/1/obdemo/etc3;/data/log1/obdemo/etc2Example of starting the observer process by using IPv6:
[root@xxx /home/admin]# su - admin-bash-4.2$ cd /home/admin/oceanbase && /home/admin/oceanbase/bin/observer -6 -I xxxx:xxxx:xxxx:xxxx:xxx:xxxx:xxxx:ebd8 -P 2882 -p 2881 -z zone1 -d /home/admin/oceanbase/store/obdemo -r '[xxxx:xxxx:xxxx:xxxx:xxx:xxxx:xxxx:ebd8]:2882:2881' -c 10001 -n obdemo -o "system_memory=30G,datafile_size=500G,config_additional_dir=/data/1/obdemo/etc3;/data/log1/obdemo/etc2"Perform the bootstrap operation on the cluster.
Connect to the started observer process by using the OBClient client. The password is empty.
[root@xxx /home/admin]# obclient -h127.0.0.1 -uroot -P2881 -p******Set the maximum SQL execution time.
obclient [(none)]> SET SESSION ob_query_timeout=1000000000;Specify the RootService machine list and start the cluster.
Specify the RootService machine list and start the cluster by using an IPv4 address.
obclient [(none)]> ALTER SYSTEM BOOTSTRAP ZONE 'zone1' SERVER '10.10.10.1:2882';Specify the RootService machine list and start the cluster by using an IPv6 address.
obclient [(none)]> ALTER SYSTEM BOOTSTRAP ZONE 'zone1' SERVER '[xxxx:xxxx:xxxx:xxxx:xxx:xxxx:xxxx:ebd8]:2882';
Notice
If an error is reported in this step, the reason may be that the startup parameter of the observer process is incorrect, the privileges on the directories related to the OBServer node are incorrect, the space of the log directory does not meet the required proportion (the log directory shares the same upper-level directory with the data directory, resulting in space occupation by the data directory), or the node memory resources are insufficient. Check these issues first, and then clear the OceanBase Database directory and start the deployment from the beginning.
Verify that the cluster is initialized.
After you perform the bootstrap operation and execute the
SHOW DATABASES;statement, ifoceanbaseappears in the database list, the cluster has been initialized.Change the password.
By default, the password of the root user under the
systenant is empty. After successful initialization, you need to change the password.ALTER USER root IDENTIFIED BY '******';
What to do next
After the cluster is created, you can create user tenants based on your business needs.
For more information about how to create a tenant by using the CLI, see Create a tenant.
