This topic describes how to deploy and manage OceanBase Database on a single server by using systemd.
Notice
Operations in this topic are applicable only to a learning or testing environment. Do not apply them to a production environment.
Prerequisites
Before you start, make sure that the following conditions are met:
You are using one of the following RPM-based operating systems:
CentOS Linux 7.X and 8.X
Anolis OS 8.X and 23
openSUSE 15.X
openEuler 22.03
You have installed jq, a command-line tool, in your environment and configured systemd as the system and service manager.
You have installed the mysql client or OceanBase Client (OBClient) in your environment for database connection.
You are going to deploy OceanBase Database V4.2.2 or later.
You have the permissions to run sudo commands.
Deploy OceanBase Database
Step 1: Install OceanBase Database
You can install OceanBase Database online or offline, depending on whether your environment is connected to the Internet.
Add the OceanBase image source.
[admin@test001 ~]$ sudo yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repoInstall OceanBase Database.
[admin@test001 ~]$ sudo yum install oceanbase-ce oceanbase-ce-libs obclientBy default, the preceding command deploys OceanBase Database of the latest version. You can install a specific version by declaring the version number. For example, you can use the
yum install oceanbase-ce-4.2.2.0command to install OceanBase Database V4.2.2. We recommend that you install the latest version.
Visit OceanBase Download Center to download OceanBase Database of the required version and the matched dependent libraries (OceanBase Libs). Then, copy the downloaded packages to your server. We recommend that you download the latest version.
Run the rpm command in the directory where the installation package is located to install OceanBase Database.
[admin@test001 ~]$ rpm -ivh oceanbase-ce-*.rpm
Step 2: Start OceanBase Database
You can start OceanBase Database by performing the following steps:
(Optional) Modify the configuration file.
Run the following command to open the configuration file and modify it by referring to this step. If you skip this step, default configurations are used.
[admin@test001 ~]$ vim /etc/oceanbase.cnfThe configuration file contains the following parameters:
mysqlPort=2881 rootPwd="" redoDir=/var/lib/oceanbase/redo dataDir=/var/lib/oceanbase/data datafile_size=2G cpu_count=16 memory_limit=6G system_memory=1G log_disk_size=13GNote
You can add other parameters to the configuration file. For more information about the parameters, see Parameter summary.
By default, the IP address of the OBServer node is
127.0.0.1and the zone iszone1. You cannot modify the two parameters.
The following table describes parameters in the configuration file.
Parameter Required? Default value Description mysqlPort No 2881 The port number for the SQL service protocol of OceanBase Database. rootPwd No Empty The password of the super administrator ( root@sys) of the OceanBase cluster. We recommend that you set a complex password.redoDir No /var/lib/oceanbase/redo The directory for storing clogs, ilogs, and slogs. We recommend that you set the directory on a separate disk. dataDir No /var/lib/oceanbase/data The directory for storing SSTables and other data. We recommend that you set the directory on a separate disk. datafile_size No 0 The size of the data file block_fileon the corresponding OBServer node. If this parameter is not configured, thedatafile_disk_percentageparameter takes effect. For more information, see datafile_size and datafile_disk_percentage.cpu_count No 0 The total number of CPU cores that OceanBase Database can use. If you set the parameter to 0, the system will automatically detect the number of CPU cores. memory_limit No 0 The maximum memory that the observer process can obtain from the environment. If this parameter is not configured, the memory_limit_percentageparameter takes effect. For more information about the two parameters, see memory_limit and memory_limit_percentage.system_memory No 0M The reserved system memory, which is part of memory_limit. If this parameter is not configured, OceanBase Database reserves memory for the system in adaptive mode.log_disk_size No 0 The size of the redo log disk. If this parameter is not configured, the log_disk_percentageparameter takes effect. For more information, see log_disk_size and log_disk_percentage.Start OceanBase Database.
[admin@test001 ~]$ sudo systemctl start oceanbase
Step 3: Connect to OceanBase Database
In this example, OBClient is used to connect to OceanBase Database. Run the following command:
[admin@test001 ~]$ obclient -h127.0.0.1 -uroot@sys -P2881 -p -A oceanbase
where
-hspecifies the IP address for connecting to OceanBase Database. If you start OceanBase Database by using systemd, the IP address is127.0.0.1by default.-uspecifies the OceanBase Database account in theusername@tenant nameformat. The default username of the administrator of a MySQL tenant isroot.-Pspecifies the port for connecting to OceanBase Database. If you start OceanBase Database by using systemd, the port number is2881by default.-pspecifies the password of the tenant account for connecting to OceanBase Database. Instead of providing the password in the command, we recommend that you enter the password as prompted after you run the command. This way, the password is masked.-Aspecifies not to automatically retrieve the statistical information when connecting to OceanBase Database.oceanbasespecifies the name of the database to access. You can change it to the name of a business database.
Manage OceanBase Database
Currently, you can use systemd only to start, stop, and view the status of OceanBase Database.
View the status of OceanBase Database
[admin@test001 ~]$ sudo systemctl status oceanbaseOceanBase Database may be in one of the following states:
If the value of the
Activefield isactive (running), and that of theStatusfield isService is running, OceanBase Database is being started.If the value of the
Activefield isactive (running), and that of theStatusfield isService is ready, OceanBase Database is successfully started.If the value of the
Activefield isinactive (dead), OceanBase Database is stopped.If the value of the
Activefield isfailed, an error occurred to OceanBase Database and you must check the logs for troubleshooting.
Stop OceanBase Database
[admin@test001 ~]$ sudo systemctl stop oceanbaseUninstall OceanBase Database
We recommend that you stop OceanBase Database first, and then perform the following steps to uninstall it:
Delete the package of OceanBase Database.
If you have installed OceanBase Database online, run the following command to delete the package:
[admin@test001 ~]$ sudo yum erase packageYou must replace
packagewith the actual name of the package to be deleted. To view the package name, run theyum list | grep oceanbasecommand.If you have installed OceanBase Database offline, run the following command to delete the package:
[admin@test001 ~]$ sudo rpm -e packageYou must replace
packagewith the actual name of the package to be deleted. To view the package name, run therpm -qa | grep oceanbasecommand.(Optional) Delete the data of OceanBase Database.
After you perform the preceding step, OceanBase Database is uninstalled from your environment, but the database data still exists. If you redeploy OceanBase Database later, you can view and use the data.
After you perform this step, the data of OceanBase Database is completely deleted.
Delete the installation directory of OceanBase Database.
[admin@test001 ~]$ rm -rf /home/admin/oceanbaseDelete the data directory of OceanBase Database.
[admin@test001 ~]$ rm -rf /var/lib/oceanbase
References
You can log on to the cluster and run the
ALTER USERcommand to modify the user password. For more information, see ALTER USER.For more information about how to connect to OceanBase Database after the deployment, see Connect to OceanBase Database.