oceanbase安装

环境信息: CentOS Linux release 7.2.1511
安装版本: 3.1.0 单机

1、安装步骤
通过 YUM 软件源安装 OBD

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

2、部署 OceanBase 数据库
2.1、增加配置文件
本地安装:即中控机器和目标机器是同一台机器,配置文件
单机安装:即中控机器和目标机器不是同一台机器,且目标机器只有一台,配置文件
分布式安装:配置文件
配置信息如下

[root@xlucas1 oceanbase]# pwd
/opt/oceanbase
[root@xlucas1 oceanbase]# cat mini-local-example.yaml 
oceanbase-ce:
  servers:
    # Please don't use hostname, only IP can be supported
    - 127.0.0.1
  global:
    home_path: /opt/oceanbase/data
    #这个路径一定要是是空的,否则会安装失败
    # 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: 2883
    rpc_port: 2882
    zone: zone1
    cluster_id: 1
    datafile_size: 8G
    # 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

2.2、安装
注意这个路径是需要指定到配置文件

[root@xlucas1 oceanbase]# obd cluster deploy xlucas -c /opt/oceanbase/mini-local-example.yaml

安装成功提示

[root@xlucas1 oceanbase]# obd cluster deploy xlucas -c /opt/oceanbase/mini-local-example.yaml 
oceanbase-ce-3.1.0 already installed
+-------------------------------------------------------------------+
|                              Packages                             |
+--------------+---------+------------------------------------------+
| Repository   | Version | Md5                                      |
+--------------+---------+------------------------------------------+
| oceanbase-ce | 3.1.0   | 56f57e9843e719d830ec03c206d914f4b3adc82b |
+--------------+---------+------------------------------------------+
Open ssh connection ok
Remote oceanbase-ce-3.1.0-56f57e9843e719d830ec03c206d914f4b3adc82b repository install ok
Remote oceanbase-ce-3.1.0-56f57e9843e719d830ec03c206d914f4b3adc82b repository lib check ok
127.0.0.1 initializes cluster work home
xlucas deployed

3、使用数据库
3.1、启动数据库

[root@xlucas1 oceanbase]# obd cluster start xlucas
Get local repositories and plugins ok
[WARN] (127.0.0.1) fs.aio-max-nr must not be less than 1048576 (Current value: 65536)
[WARN] (127.0.0.1) open files number must not be less than 655350 (Current value: 65535)
Start observer ok
observer program health check ok
Connect to observer ok
Initialize cluster
Cluster bootstrap ok
Wait for observer init ok
+---------------------------------------------+
|                   observer                  |
+-----------+---------+------+-------+--------+
| ip        | version | port | zone  | status |
+-----------+---------+------+-------+--------+
| 127.0.0.1 | 3.1.0   | 2883 | zone1 | active |
+-----------+---------+------+-------+--------+
xlucas running

3.2、查看数据库状态

[root@xlucas1 oceanbase]# obd cluster display xlucas
Get local repositories and plugins ok
Connect to observer ok
Wait for observer init ok
+---------------------------------------------+
|                   observer                  |
+-----------+---------+------+-------+--------+
| ip        | version | port | zone  | status |
+-----------+---------+------+-------+--------+
| 127.0.0.1 | 3.1.0   | 2883 | zone1 | active |
+-----------+---------+------+-------+--------+

3.3、安装 OceanBase 数据库客户端 OBClient

sudo yum install -y obclient

运行以下命令,使用 OBClient 客户端连接 OceanBase 数据库:

obclient -h<your_ip> -P<observer_mysql_port> -uroot
[root@xlucas1 ~]# obclient -h127.0.0.1 -P2883 -uroot
Welcome to the OceanBase.  Commands end with ; or \g.
Your MySQL connection id is 3221487655
Server version: 5.7.25 OceanBase 3.1.0 (r-) (Built May 30 2021 11:21:29)

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)]> 

3.4、简单使用

MySQL [oceanbase]> select svr_ip,svr_port, cpu_total, mem_total, disk_total, zone from __all_virtual_server_stat;
+-----------+----------+-----------+------------+------------+-------+
| svr_ip    | svr_port | cpu_total | mem_total  | disk_total | zone  |
+-----------+----------+-----------+------------+------------+-------+
| 127.0.0.1 |     2882 |        14 | 4294967296 | 8589934592 | zone1 |
+-----------+----------+-----------+------------+------------+-------+
1 row in set (0.007 sec)

5、遇到问题:
1、没有指定到配置文件,安装会报错,找不到配置文件

[root@xlucas1 oceanbase]# obd cluster deploy xlucas -c /opt/oceanbase/
[ERROR] copy error
[ERROR] Failed to create deploy: xlucas. please check you configuration file

2、在部署数据库的时候,配置文件中的home_path参数对应的路径要是空路径,否则会报错

[root@xlucas1 oceanbase]# obd cluster deploy xlucas -c /opt/oceanbase/mini-local-example.yaml 
Update OceanBase-community-stable-el7 ok
Update OceanBase-development-kit-el7 ok
Download oceanbase-ce-3.1.0-1.el7.x86_64.rpm (44.17 M): 100% [####################################################################################################################################################] Time: 0:00:59 777.72 kB/s
Package oceanbase-ce-3.1.0 is available
install oceanbase-ce-3.1.0 for local ok
+-------------------------------------------------------------------+
|                              Packages                             |
+--------------+---------+------------------------------------------+
| Repository   | Version | Md5                                      |
+--------------+---------+------------------------------------------+
| oceanbase-ce | 3.1.0   | 56f57e9843e719d830ec03c206d914f4b3adc82b |
+--------------+---------+------------------------------------------+
Open ssh connection ok
Remote oceanbase-ce-3.1.0-56f57e9843e719d830ec03c206d914f4b3adc82b repository install ok
Remote oceanbase-ce-3.1.0-56f57e9843e719d830ec03c206d914f4b3adc82b repository lib check !!
[WARN] 127.0.0.1 oceanbase-ce-3.1.0-56f57e9843e719d830ec03c206d914f4b3adc82b require: libmariadb.so.3

Try to get lib-repository
Download oceanbase-ce-libs-3.1.0-1.el7.x86_64.rpm (413.07 K): 100% [##############################################################################################################################################] Time: 0:00:00 826.11 kB/s
Package oceanbase-ce-libs-3.1.0 is available
install oceanbase-ce-libs-3.1.0 for local ok
Use oceanbase-ce-libs-3.1.0-b70d3839280f145a86af26811bbfcdfaeb645509 for oceanbase-ce-3.1.0-56f57e9843e719d830ec03c206d914f4b3adc82b
Remote oceanbase-ce-libs-3.1.0-b70d3839280f145a86af26811bbfcdfaeb645509 repository install ok
Remote oceanbase-ce-3.1.0-56f57e9843e719d830ec03c206d914f4b3adc82b repository lib check ok
127.0.0.1 initializes cluster work home
[ERROR] fail to init 127.0.0.1 home path: /opt/oceanbase is not empty