Install deployment tools for OceanBase obdeploy
OceanBase Deploy (OBD) is the installation and deployment tool of OceanBase open source software. OBD is also a package manager, which can be used to manage all open source software of OceanBase. In the following section, we manually compile the products of OceanBase, so OBD is needed for real deployment.
Option 1: install with RPM package (Centos 7 and above)
sudo yum install -y yum-utils sudo yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo sudo yum install -y ob-deploy source /etc/profile.d/obd.sh
Scenario 2: install using source code
Before using the source code to install OBD, please confirm that you have installed the following dependencies:
- gcc
- wget
- python-devel
- openssl-devel
- xz-devel
- mysql-devel
Python 2 is installed using the following command:
pip install -r requirements.txt sh build.sh source /etc/profile.d/obd.sh
Python 3 is installed using the following command:
pip install -r requirements3.txt sh build.sh source /etc/profile.d/obd.sh
compile OceanBase Source code
First, ensure that the following software has been installed
- Fedora based (, including CentOS, Fedora, OpenAnolis, RedHat, etc.)
yum install git wget rpm* cpio make glibc-devel glibc-headers binutils
- Debian based (, including Debian, Ubuntu, etc.)
apt-get install git wget rpm rpm2cpio cpio make build-essential binutils
- SUSE based (, including SUSE, openSUSE, etc.)
zypper install git wget rpm cpio make glibc-devel binutils
Enter the root directory of the downloaded oceanbase source code, and then compile OB in debug mode
bash build.sh debug --init --make -j16
This will generate a subdirectory under the current directory: build_debug and enter the subdirectory
cd build_debug
Create a mirror based on the local directory. This command is mainly used to start the self compiled OceanBase open source software using OBD. You can add the compiled product to the local warehouse through this command, and then you can start it using the commands related to obd cluster
make DESTDIR=./ install && obd mirror create -n oceanbase-ce -V 3.1.0 -p ./usr/local -t my-oceanbase
use
obd mirror list
Command to check whether the image is successfully generated. If the image with type local is displayed, it is successful
+------------------------------------------------------------+ | Mirror Repository List | +--------------------------------+--------+------------------+ | name | type | update time | +--------------------------------+--------+------------------+ | OceanBase-community-stable-el7 | remote | 2021-06-18 13:42 | | OceanBase-development-kit-el7 | remote | 2021-06-18 13:42 | | local | local | 2021-06-18 16:35 | +--------------------------------+--------+------------------+
use obdeploy Deploy OceanBase
Select profile
There are many configuration parameters for deploying OceanBase using OBD. Here is a local single node configuration example: mini local example Yaml, note that the following tag should be consistent with the tag specified by ` - t 'when the image was just generated. The following home_path is also specified as the directory for which you have permission
oceanbase-ce: tag: my-oceanbase servers: # Please don't use hostname, only IP can be supported - 127.0.0.1 global: home_path: /root/observer # Please set devname as the network adaptor's name whose ip is in the setting of severs. # if set severs as "127.0.0.1", please set devname as "lo" # if current ip is 192.168.1.10, and the ip's network adaptor's name is "eth0", please use "eth0" devname: lo mysql_port: 2881 rpc_port: 2882 zone: zone1 cluster_id: 1 # please set memory limit to a suitable value which is matching resource. memory_limit: 8G system_memory: 4G stack_size: 512K cpu_count: 16 cache_wash_threshold: 1G __min_full_resource_pool_memory: 268435456 workers_per_cpu_quota: 10 schema_history_expire_time: 1d # The value of net_thread_count had better be same as cpu's core number. net_thread_count: 4 sys_bkgd_migration_retry_num: 3 minor_freeze_times: 10 enable_separate_sys_clog: 0 enable_merge_by_turn: FALSE datafile_disk_percentage: 20 syslog_level: INFO enable_syslog_recycle: true max_syslog_file_count: 4
Deploy and start database
# This command checks for home_path and data_ Whether the directory pointed to by dir is empty. # If the directory is not empty, an error is reported. At this time, you can add the - f option to force emptying. obd cluster deploy lo -c mini-local-example.yaml # This command checks the system parameter FS Whether AIO Max NR is not less than 1048576. # Usually, a machine starts a node without modifying FS aio-max-nr. # When a machine needs to start four or more nodes, be sure to modify FS aio-max-nr. obd cluster start lo
View cluster status
# See the list of clusters managed by obd obd cluster list # View lo cluster status obd cluster display lo
So far, OceanBase compiled by ourselves has been deployed and started in a single node manner.
use obclient Connect the deployed OceanBase
What is OceanBase Client
OceanBase Client (OBClient for short) is a client tool developed based on MariaDB. You can use OBClient to access the cluster of OceanBase database. OBClient adopts GPL protocol.
OBClient depends on libobclient. Libobclient is an OceanBase C API Lib library developed based on mariadb-connector-c of MariaDB. Libobclient allows C/C + + programs to access the OceanBase database cluster in a relatively low-level way. Libobclient supports the latest data model using the OceanBase database. Libobclient adopts LGPL protocol.
Install OBClient
Option 1: install with RPM package (Centos 7 and above)
# Add yum source sudo yum install -y yum-utils sudo yum-config-manager \ --add-repo \ https://mirrors.aliyun.com/oceanbase/OceanBase.repo # Install OBClient sudo yum install obclient
Scenario 2: install using source code
pack obclient of rpm package sh obclient-build.sh Enter into libobclient Warehouse of cd rpm #Package the rpm of libobclient, which is mainly so and header files sh libobclient-build.sh #To install, you need to install libobclient's RPM first and then obclient's rpm
When using the installation method of scheme 1, the author found that obclient was installed under / u01/obclient. This is also very strange. After installation, the obclient command cannot be used directly. First, add the execution PATH of obclient to the PATH environment variable
export PATH="$PATH:/u01/obclient/bin"
Connect OceanBase
Run the following command to connect to the OceanBase database using the OBclient client:
obclient -h<your_ip> -P<observer_mysql_port> -uroot
Where, < your_ IP > is the IP of your machine. By default, observer uses port 33331 to connect to MySQL. If you change the port, use your actual port number here. as
obclient -h127.0.0.1 -P2881 -uroot
Return the following information:
Welcome to the OceanBase. Commands end with ; or \g. Your MySQL connection id is 3221487629 Server version: 5.7.25 OceanBase 3.1.0 (r-524427c4555e2c4a9e81992d60a6ad01e7903fc8) (Built Jun 18 2021 11:10:57) Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MySQL [(none)]>
Verify OceanBase
Run the following command to verify that OceanBase is operating properly:
MySQL [(none)]> use oceanbase Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed MySQL [oceanbase]> SELECT * FROM __all_server;
The following results are returned:
+----------------------------+----------------------------+-----------+----------+----+-------+------------+-----------------+--------+----------------------+ | gmt_create | gmt_modified | svr_ip | svr_port | id | zone | inner_port | with_rootserver | status | block_migrate_in_time| +----------------------------+----------------------------+-----------+----------+----+-------+------------+-----------------+--------+----------------------+ | 2021-06-18 14:27:37.564943 | 2021-06-18 14:28:25.367106 | 127.0.0.1 | 2882 | 1 | zone1 | 2881 | 1 | active | 0| +----------------------------+----------------------------+-----------+----------+----+-------+------------+-----------------+--------+----------------------+ 1 row in set (0.002 sec)
Stop cluster
obd cluster stop lo
Destroy cluster
# If the cluster fails to start, some processes may stay. # At this point, you can use the - f option to forcibly stop and destroy the cluster obd cluster destroy lo