软件下载:

​https://open.oceanbase.com/softwareCenter/community​

本次使用为单节点部署。


1,软件安装

[root@db01 ob]# rpm -ivh libobclient-2.0.0-2.el7.x86_64.rpm
warning: libobclient-2.0.0-2.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID e9b4a7aa: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:libobclient-2.0.0-2.el7 ################################# [100%]
[root@db01 ob]# rpm -ivh oceanbase-ce-libs-3.1.0-1.el7.x86_64.rpm
warning: oceanbase-ce-libs-3.1.0-1.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID e9b4a7aa: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:oceanbase-ce-libs-3.1.0-1.el7 ################################# [100%]
[root@db01 ob]# rpm -ivh oceanbase-ce-3.1.0-1.el7.x86_64.rpm
warning: oceanbase-ce-3.1.0-1.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID e9b4a7aa: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:oceanbase-ce-3.1.0-1.el7 ################################# [100%]
[root@db01 ob]# rpm -ivh obproxy-3.1.0-1.el7.x86_64.rpm
warning: obproxy-3.1.0-1.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID e9b4a7aa: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:obproxy-3.1.0-1.el7 ################################# [100%]
[root@db01 ob]#


2,初始化数据,日志目录

#100G大小要求

mkdir /data
mkdir /redo
chown admin:admin /data
chown admin:admin /redo
su - admin
mkdir -p ~/oceanbase/store/obdemo /data/obdemo/{sstable,etc3} /redo/obdemo/{clog,ilog,slog,etc2}
for f in {clog,ilog,slog,etc2}; do ln -s /redo/obdemo/$f ~/oceanbase/store/obdemo/$f ; done
for f in {sstable,etc3}; do ln -s /data/obdemo/$f ~/oceanbase/store/obdemo/$f; done

#系统参数修改

#系统参数/etc/sysctl.conf,/etc/security/limits.conf
https://open.oceanbase.com/articles/8600144


3,启动ob-server

echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/oceanbase/lib' >> ~/.bash_profile
. ~/.bash_profile
#启动ob server:

cd ~/oceanbase &&
bin/observer -i ens192 -p 2881 -P 2882 -z zone1 -d ~/oceanbase/store/obdemo -r '192.168.5.200:2882:2881' -c 20210912 -n obdemo -o "memory_limit=8G,cache_wash_threshold=1G,__min_full_resource_pool_memory=268435456,system_memory=3G,memory_chunk_cache_size=128M,cpu_count=16,net_thread_count=4,datafile_size=50G,stack_size=1536K,config_additional_dir=/data/obdemo/etc3;/redo/obdemo/etc2"

#检查集群状态:

[admin@db01 oceanbase]$ ps -ef|grep obse
admin 9385 1 66 04:32 ? 00:04:12 bin/observer -i ens192 -p 2881 -P 2882 -z zone1 -d /home/admin/oceanbase/store/obdemo -r 127.0.0.1:2882:2881 -c 20210912 -n obdemo -d /home/admin/oceanbase/store/obdemo
admin 10763 9356 0 04:38 pts/1 00:00:00 grep --color=auto obse
[admin@db01 oceanbase]$

[admin@db01 oceanbase]$ netstat -ntlp|grep ob
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 0.0.0.0:2881 0.0.0.0:* LISTEN 9385/bin/observer
tcp 0 0 0.0.0.0:2882 0.0.0.0:* LISTEN 9385/bin/observer

手动部署 OceanBase 集群(二)_OceanBase

4,集群自举(初始化)


执行bootstrap成功。

[admin@db01 oceanbase]$ obclient -h 192.168.5.200 -u root -P 2881 -p -c -A
Enter password:
Welcome to the OceanBase. Commands end with ; or \g.
Your MySQL connection id is 3221225477
Server version: 5.7.25 OceanBase 3.1.1 (r4-8c615943cbd25a6f7b8bdfd8677a13a21709a05e) (Built Oct 21 2021 10:33:14)

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)]> set session ob_query_timeout=1000000000; alter system bootstrap ZONE 'zone1' SERVER '192.168.5.200:2882';
Query OK, 0 rows affected (0.000 sec)

Query OK, 0 rows affected (16.046 sec)

执行初始化成功:

手动部署 OceanBase 集群(二)_OceanBase_02

5,ob-proxy

创建用户 proxyro:

使用root@sys登陆数据库:
#密码为空
[admin@db01 oceanbase]$ obclient -h 192.168.5.200 -u root@sys -P 2881 -p -c -A
Enter password:
Welcome to the OceanBase. Commands end with ; or \g.
Your MySQL connection id is 3221487723
Server version: 5.7.25 OceanBase 3.1.1 (r4-8c615943cbd25a6f7b8bdfd8677a13a21709a05e) (Built Oct 21 2021 10:33:14)

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)]> grant select on oceanbase.* to proxyro identified by 'SWoLCQRH' ;
Query OK, 0 rows affected (0.040 sec)

MySQL [(none)]>

启动obproxy:

#-c 对应集群的名称,和前面的observer的启动参数对应。

/home/admin/obproxy-3.1.0/bin/obproxy -r "127.0.0.1:2881" -p 2883 -o "enable_strict_kernel_release=false,enable_cluster_checkout=false,enable_metadb_used=false" -c obdemo

手动部署 OceanBase 集群(二)_OceanBase_03手动部署 OceanBase 集群(二)_OceanBase_04

端口状态检查:

[root@db01 ~]# netstat -ntlp |grep obproxy
tcp 0 0 0.0.0.0:2883 0.0.0.0:* LISTEN 21258/obproxy
tcp 0 0 0.0.0.0:2884 0.0.0.0:* LISTEN 21258/obproxy
[root@db01 ~]#

修改 OBPROXY 连接 OceanBase 集群用户 ​proxyro​ 的密码。这样 OBPROXY 才能跟 OceanBase 集群正常连接:

#登录 OBPROXY:

#登录用户名:root@proxysys, 端口:2883 ,初始密码:空。

[root@db01 bin]# obclient -h 127.0.0.1 -u root@proxysys -P 2883 -p
Enter password:
Welcome to the OceanBase. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.25

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)]> show proxyconfig like '%sys_password%';
+------------------------+-------+--------------------------------+-------------+---------------+
| name | value | info | need_reboot | visible_level |
+------------------------+-------+--------------------------------+-------------+---------------+
| observer_sys_password1 | | password for observer sys user | false | SYS |
| observer_sys_password | | password for observer sys user | false | SYS |
| obproxy_sys_password | | password for obproxy sys user | false | SYS |
+------------------------+-------+--------------------------------+-------------+---------------+
3 rows in set (0.001 sec)

MySQL [(none)]>
MySQL [(none)]> alter proxyconfig set observer_sys_password = 'SWoLCQRH' ;
Query OK, 0 rows affected (0.009 sec)

通过OBPROXY 2883连接数据库:

[admin@db01 oceanbase]$ obclient -h127.1 -uroot@sys#obdemo -P2883  -c -A oceanbase
Welcome to the OceanBase. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.6.25 OceanBase 3.1.1 (r4-8c615943cbd25a6f7b8bdfd8677a13a21709a05e) (Built Oct 21 2021 10:33:14)

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 [oceanbase]>

MySQL [oceanbase]> show databases;
+--------------------+
| Database |
+--------------------+
| oceanbase |
| information_schema |
| mysql |
| SYS |
| LBACSYS |
| ORAAUDITOR |
| test |
+--------------------+
7 rows in set (0.011 sec)

MySQL [oceanbase]>

MySQL [oceanbase]> show processlist;
+------+--------+------+-----------------+-----------+-------------+-------------------+-------------------+-------+-------+
| Id | Tenant | User | Host | db | trans_count | svr_session_count | state | tid | pid |
+------+--------+------+-----------------+-----------+-------------+-------------------+-------------------+-------+-------+
| 5 | sys | root | 127.0.0.1:38306 | oceanbase | 0 | 1 | MCS_ACTIVE_READER | 21258 | 21258 |
+------+--------+------+-----------------+-----------+-------------+-------------------+-------------------+-------+-------+
1 row in set (0.001 sec)

MySQL [oceanbase]> show full processlist;
+------------+---------+--------+---------------------+-----------+---------+------+--------+-----------------------+---------------+------+--------------+
| Id | User | Tenant | Host | db | Command | Time | State | Info | Ip | Port | Proxy_sessid |
+------------+---------+--------+---------------------+-----------+---------+------+--------+-----------------------+---------------+------+--------------+
| 3221487800 | root | sys | 192.168.5.200:33134 | oceanbase | Query | 0 | ACTIVE | show full processlist | 192.168.5.200 | 2881 | 4 |
| 3221487797 | proxyro | sys | 192.168.5.200:33130 | oceanbase | Sleep | 5 | SLEEP | NULL | 192.168.5.200 | 2881 | 3 |
+------------+---------+--------+---------------------+-----------+---------+------+--------+-----------------------+---------------+------+--------------+
2 rows in set (0.003 sec)
MySQL [oceanbase]>


6,创建租户、数据库,表

6.1创建租户

[root@db01 redo]# mysql -h 192.168.5.200 -u root@sys -P 2881 -p -c -A
Welcome to the OceanBase. Commands end with ; or \g.
Your MySQL connection id is 3221487740
Server version: 5.7.25 OceanBase 3.1.1 (r4-8c615943cbd25a6f7b8bdfd8677a13a21709a05e) (Built Oct 21 2021 10:52:05)

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 [oceanbase]>
MySQL [oceanbase]> alter resource unit sys_unit_config min_cpu=5;
Query OK, 0 rows affected (0.010 sec)

MySQL [oceanbase]>
MySQL [oceanbase]> CREATE resource unit S4C1G max_cpu=4, min_cpu=4, max_memory='1G', min_memory='1G', max_iops=10000, min_iops=1000, max_session_num=1000000, max_disk_size='1024G';
Query OK, 0 rows affected (0.010 sec)

MySQL [oceanbase]>
MySQL [oceanbase]> CREATE resource pool my_pool unit = 'S4C1G', unit_num = 1;
Query OK, 0 rows affected (0.018 sec)

MySQL [oceanbase]> create tenant obmysql resource_pool_list=('my_pool'), primary_zone='RANDOM',comment 'mysql tenant/instance', charset='utf8' set ob_tcp_invited_nodes='%', ob_compatibility_mode='mysql';

Query OK, 0 rows affected (3.692 sec)


6.2 使用租户登录,创建表

[root@db01 ~]# obclient -h 127.1 -uroot@obmysql -P2881 -p -c -A test
Enter password:
Welcome to the OceanBase. Commands end with ; or \g.
Your MySQL connection id is 3221487994
Server version: 5.7.25 OceanBase 3.1.1 (r4-8c615943cbd25a6f7b8bdfd8677a13a21709a05e) (Built Oct 21 2021 10:33:14)

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 [test]> show tables;
+----------------+
| Tables_in_test |
+----------------+
| t1 |
| t2 |
| t3 |
+----------------+
3 rows in set (0.003 sec)
MySQL [test]>
MySQL [test]> create table t4 (id int);
Query OK, 0 rows affected (0.129 sec)

MySQL [test]> show tables;
+----------------+
| Tables_in_test |
+----------------+
| t1 |
| t2 |
| t3 |
| t4 |
+----------------+
4 rows in set (0.002 sec)

MySQL [test]>

参考地址:

https://open.oceanbase.com/articles/8600151