OceanBase在2021年6月1日公布了社区版(官网:open.oceanbase.com)。立即有很多网友开始下载使用。部分朋友在安装部署上不是很顺利,本文主要是提供一种社区版安装方法,让大家了解这个步骤和原理。

在社区版发布之前,在OceanBase 1.0版本发布之后,OceanBase软件从来只有一个版本(一个rpm包)。不管此前你从哪个渠道获取的,不管是什么形态(可执行文件、rpm包、docker镜像),它跟蚂蚁内部用OceanBase都是一个代码分支(功能都是一样的)。区别只是那个具体的软件版本不一样(如1.4.7,2.2.3,2.2.5,2.2.7等)。在社区版发布之后,才有社区版和企业版区分,二者功能上确有区别,企业版多了更多高级功能(具体请看官网 open.oceanbase.com )。

但是OceanBase最核心的基本能力都一样,包括:多副本Paxos协议强同步、SQL引擎(兼容MySQL)、分布式事务、水平扩展。所以就部署方法而言,社区版和企业版的部署方法都是一样的。以前总结的OceanBase部署经验同样适用于社区版。

OceanBase部署的方法比ORACLE RAC简单多了,新手觉得难只是因为没有搞清楚这里面的步骤原理。当机器资源和环境都初始化正确的时候,命令行下5分钟就可以重新部署一个OceanBase集群。很多人喜欢自动化脚本部署,觉得省事。但弊端也很明显。如果部署成功了,不知道为什么成功;部署报错了,也不知道为什么报错。除非你研究自动化部署脚本的程序 。

官网的社区版部署方法像用一个自动化程序简化部署操作,这是内部开发和测试常用的脚本,百试不爽!它的挑战在于外部用户机器环境五花八门,用户数据库运维经验不一。所以这套方法在外部开始时可能还不够成熟。所以这里我介绍的方法不用官网社区版发布的部署程序(OBD)。

下面的方法主要是供初学者能把社区版跑起来,会省略一些OS内核参数、数据库内核参数的配置过程的。所以这个方法装好的OB不适合立即跑性能测试。

首先是下载社区版。

这里不考虑源码编译安装了。按官网方法下载。

yum install -y yum-utils
yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo# 创建一个目录用于下载
mkdir rpm
cat > rpm_list <<EOF
oceanbase-ce-3.1.0-1.el7.x86_64.rpm
oceanbase-ce-libs-3.1.0-1.el7.x86_64.rpm
obproxy-3.1.0-1.el7.x86_64.rpm
EOF
wget -B https://mirrors.aliyun.com/oceanbase/community/stable/el/7/x86_64/ -i rpm_list -P rpm

先不要安装rpm包。

第二机器配置。

OceanBase机器里关键资源是内存。就目前而言,4C8G的环境将OB跑起来是没问题的。如果条件允许,尽可能用更大资源的机器。比如说我用的16C64G的阿里云ECS。机器资源多一点,我可以多起几个OB进程,在单机上模拟搭建一个集群。

机器磁盘也单独说一下。这关系到OB的数据文件、日志文件的存储。这个路径比较多确实有点难记。初学时简单点,机器搞一块独立的裸盘即可(/dev/sdb)。磁盘的空间稍微大于内存的4倍吧。

第三是操作系统配置。

为缩减篇幅,不说OS内核参数设置了,那些是关乎性能的。这里目标降低为跑起来。

将物理盘格式化为文件系统 /data

[root@obpilot ~]# fdisk /dev/vdb
[root@obpilot ~]# mkfs -t ext4 /dev/vdb1
[root@obpilot ~]# mkdir -p /data
[root@obpilot ~]# mount -t ext4 /dev/vdb1 /data

官网OBD安装的OB会运行在root用户下。这个习惯很不好。生产的OB默认运行在admin用户下,这里也这么做。要换成其他用户也可以,先按admin用户安装好熟悉一下特点再考虑换其他用户。

[root@obpilot ~]# useradd admin
[root@obpilot ~]# rpm -ivh rpm/*
准备中...                          ################################# [100%]
正在升级/安装...1:oceanbase-ce-libs-3.1.0-1.el7    ################################# [ 33%]2:oceanbase-ce-3.1.0-1.el7         ################################# [ 67%]3:obproxy-3.1.0-1.el7              ################################# [100%]

查看一下具体安装目录。

[root@obpilot ~]# rpm -ql oceanbase-ce-3.1.0-1.el7.x86_64
/home/admin/oceanbase
/home/admin/oceanbase/bin
/home/admin/oceanbase/bin/import_time_zone_info.py
/home/admin/oceanbase/bin/observer
/home/admin/oceanbase/etc
/home/admin/oceanbase/etc/timezone_V1.log
[root@obpilot ~]# rpm -ql obproxy-3.1.0-1.el7
/home/admin/obproxy-3.1.0/bin
/home/admin/obproxy-3.1.0/bin/obproxy
/home/admin/obproxy-3.1.0/bin/obproxyd.sh
[root@obpilot ~]#

第四启动OB进程。

在 admin用户下启动,在oceanbase主目录启动,严格按照下面步骤执行命令。

[admin@obpilot oceanbase]$ su - admin
[admin@obpilot oceanbase]$ mkdir -p /data/observer01/store/{sort_dir,sstable,clog,ilog,slog}
[admin@obpilot oceanbase]$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/admin/oceanbase/lib/
[admin@obpilot oceanbase]$ cd /data/observer01 && /home/admin/oceanbase/bin/observer -r 172.20.249.39:2882:2881 -o __min_full_resource_pool_memory=268435456,memory_limit=8G,system_memory=4G,stack_size=512K,cpu_count=16,cache_wash_threshold=1G,workers_per_cpu_quota=10,schema_history_expire_time=1d,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_size=50G,enable_syslog_recycle=True,max_syslog_file_count=10 -z zone1 -p 2881 -P 2882 -c 1 -d /data/observer01/store -i eth0 -l INFO

上面黄色底色的都是要根据实际环境修改的

1. -d 是指定存放 OB节点的数据文件和日志文件的目录。这个目录下必须存在几个子目录。如果你重装了,把 -d 的目录清空重新创建。

2. -r 是指定OB节点的信息。上面是单节点。后面再看三节点的示例。

3. -o 是指定OB进程启动参数,如果你熟悉OB参数,可以在这里调整。这里的 memory_limit=8G,表示启动一个8G的OB进程。如果你机器实际内存比这个大,可以改大它。内存越大的话,你甚至可以去掉这些内存相关的参数。data_size是数据文件大小,确保可以分配出来并且分配后剩余空间比例不低于10%以及是内存 2 倍以上。

4. -i 是网卡名,跟 -r 后面的IP要对应上。

5. 启动目录改到 /data/observer01下,这样相关的运行日志会在这个目录下。后面还要启动多个节点,每个节点的observer进程运行日志是分开存放的。

启动后能看到observer进程,监听端口(2881和2882),那这一步就成功了。

rs list: 172.20.249.39:2882:2881
optstr: __min_full_resource_pool_memory=268435456,memory_limit=8G,system_memory=4G,stack_size=512K,cpu_count=16,cache_wash_threshold=1G,workers_per_cpu_quota=10,schema_history_expire_time=1d,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_size=50G,enable_syslog_recycle=True,max_syslog_file_count=10
zone: zone1
mysql port: 2881
rpc port: 2882
cluster id: 1
data_dir: /data/observer01/store
devname: eth0
log level: INFO
[2021-06-26 17:27:34.052449] ERROR [LIB] pidfile_test (utility.cpp:1153) [9005][0][Y0-0000000000000000] [lt=0] fid file doesn't exist(pidfile="run/observer.pid") BACKTRACE:0x90a107e 0x90008fb 0x24c152f 0x251bb2d 0x90a6215 0x24be1a8 0x7f1a0a400495 0x24bd4e9
[admin@obpilot oceanbase]$ ps -ef|grep observer
admin     9006     1 73 17:27 ?        00:00:04 bin/observer -r 172.20.249.39:2882:2881 -o __min_full_resource_pool_memory=268435456,memory_limit=8G,system_memory=4G,stack_size=512K,cpu_count=16,cache_wash_threshold=1G,workers_per_cpu_quota=10,schema_history_expire_time=1d,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_size=50G,enable_syslog_recycle=True,max_syslog_file_count=10 -z zone1 -p 2881 -P 2882 -c 1 -d /data/observer01/store -i eth0 -l INFO
admin     9577  8043  0 17:27 pts/2    00:00:00 grep --color=auto observer
[admin@obpilot oceanbase]$ netstat -ntlp
(Not all processes could be identified, non-owned process infowill 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:22              0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:2881            0.0.0.0:*               LISTEN      9006/bin/observer
tcp        0      0 0.0.0.0:2882            0.0.0.0:*               LISTEN      9006/bin/observer
[admin@obpilot oceanbase]$

说明:

如果你不是第一次启动,再次启动的时候会看到提示“ERROR [LIB] pidfile_test (utility.cpp:1153) [9005][0][Y0-0000000000000000] [lt=0] fid file doesn't exist(pidfile="run/observer.pid")”。这个报错没有实质性影响,这个信息日志级别应该用 WARN 而不是 ERROR 。希望社区版能有人把这个错误给修改了。

仅仅是进程启动了,并不代表OB部署成功了。

第五步,集群bootstrap。

不用奇怪我说集群。三副本是集群,单副本也是集群。单副本不一定是单节点。

进程第一次启动后,用mysql客户端登录(mysql版本5.5/5.6/5.7) ,root密码为空。用 obclient 也可以(需要安装 yum -y install obclient)。

[admin@obpilot oceanbase]$ mysql -h127.1 -uroot -P2881 -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 3221225473
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)]>
MySQL [(none)]>set session ob_query_timeout=1000000000; alter system bootstrap ZONE 'zone1' SERVER '172.20.249.39:2882' ;
Query OK, 0 rows affected (0.00 sec)Query OK, 0 rows affected (15.67 sec)
MySQL [(none)]> alter user root identified by '123456';
Query OK, 0 rows affected (0.02 sec)MySQL [(none)]> Bye
[admin@obpilot oceanbase]$ mysql -h127.1 -uroot@sys -P2881 -p123456 -c -A oceanbase
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 3221487636
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 [oceanbase]> show databases;
+--------------------+
| Database           |
+--------------------+
| oceanbase          |
| information_schema |
| mysql              |
| SYS                |
| LBACSYS            |
| ORAAUDITOR         |
| test               |
+--------------------+
7 rows in set (0.00 sec)MySQL [oceanbase]>

bootstrap 是学OB的第一道门槛。迈不过去就永远部署不了OB。bootstrap 原理比较复杂,根据原理或日志去找原因不是个好主意。bootstrap失败的原因通常很简单。如内存资源不够、目录权限不对、磁盘空间不够等等、多节点时间不同步(超过5ms)、多节点网络延时很大(超过50ms)。这一块有单独的文章总结,可以参考《OceanBase 2.2安装部署问题解答》。

bootstrap 成功后,用用户名 root@sys 登录后,查看数据库,可以看到多出几个database:oceanbase 。

看到 oceanbase 这个数据库,那就是真正成功了。

第六步,建租户(实例)。

租户就是实例,是逻辑实例,没有单独的进程。OceanBase在企业自己机房部署后,可以给开发提供类似云数据库的服务。Database As A Service。实例按需分配,立即分配(1分钟不到),实例资源后期可以在线调整,多退少补。OceanBase改变的是传统数据库的运维形态,DBA更像是一个资源管家,更专注于服务业务。

这一步很简单,但是很多人也会在这里碰到资源不足问题。在分配租户之前,首先得知道集群有多少资源可用。

MySQL [oceanbase]> select a.zone,concat(a.svr_ip,':',a.svr_port) observer, cpu_total, (cpu_total-cpu_assigned) cpu_free, round(mem_total/1024/1024/1024) mem_total_gb, round((mem_total-mem_assigned)/1024/1024/1024) mem_free_gb, usec_to_time(b.last_offline_time) last_offline_time, usec_to_time(b.start_service_time) start_service_time, b.status, b.build_version , usec_to_time(a.stop_time) stop_time
from __all_virtual_server_stat a join __all_server b on (a.svr_ip=b.svr_ip and a.svr_port=b.svr_port)
order by a.zone, a.svr_ip
;
+-------+--------------------+-----------+----------+--------------+-------------+----------------------------+----------------------------+--------+-------------------------------+----------------------------+
| zone  | observer           | cpu_total | cpu_free | mem_total_gb | mem_free_gb | last_offline_time          | start_service_time         | status | build_version                 | stop_time                  |
+-------+--------------------+-----------+----------+--------------+-------------+----------------------------+----------------------------+--------+-------------------------------+----------------------------+
| zone1 | 172.20.249.39:2882 |        14 |     11.5 |            4 |           3 | 1970-01-01 08:00:00.000000 | 2021-06-26 17:29:25.599983 | active | 3.1.0_-(May 30 2021 11:21:29) | 1970-01-01 08:00:00.000000 |
+-------+--------------------+-----------+----------+--------------+-------------+----------------------------+----------------------------+--------+-------------------------------+----------------------------+
1 row in set (0.00 sec)MySQL [oceanbase]> select t1.name resource_pool_name, t2.`name` unit_config_name, t2.max_cpu, t2.min_cpu, round(t2.max_memory/1024/1024/1024) max_mem_gb, round(t2.min_memory/1024/1024/1024) min_mem_gb, t3.unit_id, t3.zone, concat(t3.svr_ip,':',t3.`svr_port`) observer,t4.tenant_id, t4.tenant_name
from __all_resource_pool t1 join __all_unit_config t2 on (t1.unit_config_id=t2.unit_config_id)join __all_unit t3 on (t1.`resource_pool_id` = t3.`resource_pool_id`)left join __all_tenant t4 on (t1.tenant_id=t4.tenant_id)
order by t1.`resource_pool_id`, t2.`unit_config_id`, t3.unit_id
;-> ;
+--------------------+------------------+---------+---------+------------+------------+---------+-------+--------------------+-----------+-------------+
| resource_pool_name | unit_config_name | max_cpu | min_cpu | max_mem_gb | min_mem_gb | unit_id | zone  | observer           | tenant_id | tenant_name |
+--------------------+------------------+---------+---------+------------+------------+---------+-------+--------------------+-----------+-------------+
| sys_pool           | sys_unit_config  |       5 |     2.5 |          1 |          1 |       1 | zone1 | 172.20.249.39:2882 |         1 | sys         |
+--------------------+------------------+---------+---------+------------+------------+---------+-------+--------------------+-----------+-------------+
1 row in set (0.00 sec)

第一个sql 是查集群各个节点的剩余资源(cpu和内存,空间不管)。第二个sql是查询集群里当前资源使用细节。这里有几点解释:

1. observer 启动参数里指定了cpu_count=16,表示告诉(欺骗)observer进程主机有16个cpu,实际上observer进程只拿了14个cpu,留了2个给os。生产环境实打实的。

2. observer 启动进程里指定了memory_limit=8G,表示告诉(不是欺骗)observer进程可用8G内存,ob内部system_memory拿去了4G,还剩下4G.所以这里的memory_total是4G,然后内部租户 sys_pool用了1G,留给租户的就是3G。

细心的朋友如果计算一下cpu的分配,总cpu是14个,sys租户用了2.5,剩余是11.5.实际上实际可用的cpu不是11.5,而是9个。这个是因为 sys_unit_config的min_cpu值跟max_cpu不一样(在企业版本里,min_memory跟max_memory也不一样)。而很多人根据第一个sql计算觉得资源够,实际分配的时候不够往往就是这个原因。

所以,个人习惯,首先把这个不协调的设置改对。真希望社区版能有人把这个代码逻辑改过来。

MySQL [oceanbase]> alter resource unit sys_unit_config min_cpu=5,min_memory='1G';
Query OK, 0 rows affected (0.01 sec)MySQL [oceanbase]> select a.zone,concat(a.svr_ip,':',a.svr_port) observer, cpu_total, (cpu_total-cpu_assigned) cpu_free, round(mem_total/1024/1024/1024) mem_total_gb, round((mem_total-mem_assigned)/1024/1024/1024) mem_free_gb, usec_to_time(b.last_offline_time) last_offline_time, usec_to_time(b.start_service_time) start_service_time, b.status, b.build_version , usec_to_time(a.stop_time) stop_time from __all_virtual_server_stat a join __all_server b on (a.svr_ip=b.svr_ip and a.svr_port=b.svr_port) order by a.zone, a.svr_ip;
+-------+--------------------+-----------+----------+--------------+-------------+----------------------------+----------------------------+--------+-------------------------------+----------------------------+
| zone  | observer           | cpu_total | cpu_free | mem_total_gb | mem_free_gb | last_offline_time          | start_service_time         | status | build_version                 | stop_time                  |
+-------+--------------------+-----------+----------+--------------+-------------+----------------------------+----------------------------+--------+-------------------------------+----------------------------+
| zone1 | 172.20.249.39:2882 |        14 |        9 |            4 |           3 | 1970-01-01 08:00:00.000000 | 2021-06-26 17:29:25.599983 | active | 3.1.0_-(May 30 2021 11:21:29) | 1970-01-01 08:00:00.000000 |
+-------+--------------------+-----------+----------+--------------+-------------+----------------------------+----------------------------+--------+-------------------------------+----------------------------+
1 row in set (0.01 sec)

现在可以愉快的创建租户(实例)了。

MySQL [oceanbase]> CREATE resource unit my_unit_config 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.01 sec)MySQL [oceanbase]> CREATE resource pool pool_mysql_01 unit = 'my_unit_config', unit_num = 1;
Query OK, 0 rows affected (0.01 sec)MySQL [oceanbase]> CREATE tenant mysql01 resource_pool_list=('pool_mysql_01'), primary_zone='RANDOM',comment 'mysql tenant/instance', charset='utf8' set ob_tcp_invited_nodes='%', ob_compatibility_mode='mysql';Query OK, 0 rows affected (0.48 sec)MySQL [oceanbase]>
MySQL [oceanbase]> CREATE resource pool pool_mysql_02 unit = 'my_unit_config', unit_num = 1;
Query OK, 0 rows affected (0.00 sec)MySQL [oceanbase]>
MySQL [oceanbase]> CREATE tenant mysql02 resource_pool_list=('pool_mysql_02'), primary_zone='RANDOM',comment 'mysql tenant/instance', charset='utf8' set ob_tcp_invited_nodes='%', ob_compatibility_mode='mysql';
Query OK, 0 rows affected (0.46 sec)

我这里创建了2个租户。4C1G的mysql租户,就看看功能就行。不适合大量建表和导入数据,以及性能测试。

MySQL [oceanbase]> select * from __all_tenant;
+----------------------------+----------------------------+-----------+-------------+-------------+-----------+--------------+--------+----------------+-----------------------+-----------+-----------------------+---------------+---------------------+-------------------+------------------------+-----------------------------+-----------------------+--------------------+------------------+----------------------+---------------+
| gmt_create                 | gmt_modified               | tenant_id | tenant_name | replica_num | zone_list | primary_zone | locked | collation_type | info                  | read_only | rewrite_merge_version | locality      | logonly_replica_num | previous_locality | storage_format_version | storage_format_work_version | default_tablegroup_id | compatibility_mode | drop_tenant_time | status               | in_recyclebin |
+----------------------------+----------------------------+-----------+-------------+-------------+-----------+--------------+--------+----------------+-----------------------+-----------+-----------------------+---------------+---------------------+-------------------+------------------------+-----------------------------+-----------------------+--------------------+------------------+----------------------+---------------+
| 2021-06-26 17:29:24.242717 | 2021-06-26 17:29:24.242717 |         1 | sys         |          -1 | zone1     | zone1        |      0 |              0 | system tenant         |         0 |                     0 | FULL{1}@zone1 |                   0 |                   |                      0 |                           0 |                    -1 |                  0 |               -1 | TENANT_STATUS_NORMAL |             0 |
| 2021-06-26 19:20:13.030153 | 2021-06-26 19:20:13.030153 |      1001 | mysql01     |          -1 | zone1     | RANDOM       |      0 |              0 | mysql tenant/instance |         0 |                     0 | FULL{1}@zone1 |                   0 |                   |                      0 |                           0 |                    -1 |                  0 |               -1 | TENANT_STATUS_NORMAL |             0 |
| 2021-06-26 19:20:58.340233 | 2021-06-26 19:20:58.340233 |      1003 | mysql02     |          -1 | zone1     | RANDOM       |      0 |              0 | mysql tenant/instance |         0 |                     0 | FULL{1}@zone1 |                   0 |                   |                      0 |                           0 |                    -1 |                  0 |               -1 | TENANT_STATUS_NORMAL |             0 |
+----------------------------+----------------------------+-----------+-------------+-------------+-----------+--------------+--------+----------------+-----------------------+-----------+-----------------------+---------------+---------------------+-------------------+------------------------+-----------------------------+-----------------------+--------------------+------------------+----------------------+---------------+
3 rows in set (0.00 sec)select t1.name resource_pool_name, t2.`name` unit_config_name, t2.max_cpu, t2.min_cpu, round(t2.max_memory/1024/1024/1024) max_mem_gb, round(t2.min_memory/1024/1024/1024) min_mem_gb, t3.unit_id, t3.zone, concat(t3.svr_ip,':',t3.`svr_port`) observer,t4.tenant_id, t4.tenant_name
from __all_resource_pool t1 join __all_unit_config t2 on (t1.unit_config_id=t2.unit_config_id)join __all_unit t3 on (t1.`resource_pool_id` = t3.`resource_pool_id`)left join __all_tenant t4 on (t1.tenant_id=t4.tenant_id)
order by t1.`resource_pool_id`, t2.`unit_config_id`, t3.unit_id
;
+--------------------+------------------+---------+---------+------------+------------+---------+-------+--------------------+-----------+-------------+
| resource_pool_name | unit_config_name | max_cpu | min_cpu | max_mem_gb | min_mem_gb | unit_id | zone  | observer           | tenant_id | tenant_name |
+--------------------+------------------+---------+---------+------------+------------+---------+-------+--------------------+-----------+-------------+
| sys_pool           | sys_unit_config  |       5 |       5 |          1 |          1 |       1 | zone1 | 172.20.249.39:2882 |         1 | sys         |
| pool_mysql_01      | my_unit_config   |       4 |       4 |          1 |          1 |    1001 | zone1 | 172.20.249.39:2882 |      1001 | mysql01     |
| pool_mysql_02      | my_unit_config   |       4 |       4 |          1 |          1 |    1002 | zone1 | 172.20.249.39:2882 |      1003 | mysql02     |
+--------------------+------------------+---------+---------+------------+------------+---------+-------+--------------------+-----------+-------------+
3 rows in set (0.00 sec)

在往后就是OB的使用了。还有obproxy的部署、租户的连接。这些跟企业版也是一样的。有问题的朋友可以查看以前的文章。这里不再赘述了。

特别介绍:单副本扩容到三副本。

这里再介绍一下从单节点扩容到三节点,能看懂了表示就理解了OceanBase集群扩容原理。

chown -R admin.admin /datasu - admin
echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/admin/oceanbase/lib/" >> ~/.bash_profile
. ~/.bash_profilemkdir -p /data/observer02/store/{sort_dir,sstable,clog,ilog,slog}
cd /data/observer02/ && /home/admin/oceanbase/bin/observer -r 172.20.249.39:2882:2881 -o __min_full_resource_pool_memory=268435456,memory_limit=8G,system_memory=4G,stack_size=512K,cpu_count=16,cache_wash_threshold=1G,workers_per_cpu_quota=10,schema_history_expire_time=1d,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_size=50G,enable_syslog_recycle=True,max_syslog_file_count=10 -z zone2 -p 3881 -P 3882 -c 1 -d /data/observer02/store -i eth0 -l INFOsu - admin
mkdir -p /data/observer03/store/{sort_dir,sstable,clog,ilog,slog}
cd /data/observer03/ && /home/admin/oceanbase/bin/observer -r 172.20.249.39:2882:2881 -o __min_full_resource_pool_memory=268435456,memory_limit=8G,system_memory=4G,stack_size=512K,cpu_count=16,cache_wash_threshold=1G,workers_per_cpu_quota=10,schema_history_expire_time=1d,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_size=50G,enable_syslog_recycle=True,max_syslog_file_count=10 -z zone3 -p 4881 -P 4882 -c 1 -d /data/observer03/store -i eth0 -l INFO[admin@obpilot observer03]$ ps -ef|grep observer |grep -v grep
admin    26533     1 50 19:46 ?        00:02:57 /home/admin/oceanbase/bin/observer -r 172.20.249.39:2882:2881 -o __min_full_resource_pool_memory=268435456,memory_limit=8G,system_memory=4G,stack_size=512K,cpu_count=16,cache_wash_threshold=1G,workers_per_cpu_quota=10,schema_history_expire_time=1d,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_size=50G,enable_syslog_recycle=True,max_syslog_file_count=10 -z zone1 -p 2881 -P 2882 -c 1 -d /data/observer01/store -i eth0 -l INFO
admin    27316     1 59 19:50 ?        00:01:01 /home/admin/oceanbase/bin/observer -r 172.20.249.39:2882:2881 -o __min_full_resource_pool_memory=268435456,memory_limit=8G,system_memory=4G,stack_size=512K,cpu_count=16,cache_wash_threshold=1G,workers_per_cpu_quota=10,schema_history_expire_time=1d,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_size=50G,enable_syslog_recycle=True,max_syslog_file_count=10 -z zone2 -p 3881 -P 3882 -c 1 -d /data/observer02/store -i eth0 -l INFO
admin    27955     1 72 19:52 ?        00:00:11 /home/admin/oceanbase/bin/observer -r 172.20.249.39:2882:2881 -o __min_full_resource_pool_memory=268435456,memory_limit=8G,system_memory=4G,stack_size=512K,cpu_count=16,cache_wash_threshold=1G,workers_per_cpu_quota=10,schema_history_expire_time=1d,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_size=50G,enable_syslog_recycle=True,max_syslog_file_count=10 -z zone3 -p 4881 -P 4882 -c 1 -d /data/observer03/store -i eth0 -l INFO
[admin@obpilot observer03]$ netstat -ntlp
(Not all processes could be identified, non-owned process infowill 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:3881            0.0.0.0:*               LISTEN      27316/observer
tcp        0      0 0.0.0.0:3882            0.0.0.0:*               LISTEN      27316/observer
tcp        0      0 0.0.0.0:4881            0.0.0.0:*               LISTEN      27955/observer
tcp        0      0 0.0.0.0:4882            0.0.0.0:*               LISTEN      27955/observer
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:2881            0.0.0.0:*               LISTEN      26533/observer
tcp        0      0 0.0.0.0:2882            0.0.0.0:*               LISTEN      26533/observer
[admin@obpilot observer03]

说明:

1. -r 参数依然是第一个节点的端口(2881和2882),因为这里是集群扩容,不是新增2个集群。所以 -r 参数会决定了这个进程启动后跟哪个集群进行通信。

2. -p 和 -P 参数要不一样。每个进程监听2个端口,不能冲突。

3. 不同节点的启动目录要不一样,这样每个目录下会生成相应的log目录,里面有运行日志。

进程启动了,还要在集群里把这两个节点加进集群。

MySQL [oceanbase]> select * from __all_zone where name in ('region','status','zone_type');
+----------------------------+----------------------------+-------+-----------+-------+----------------+
| gmt_create                 | gmt_modified               | zone  | name      | value | info           |
+----------------------------+----------------------------+-------+-----------+-------+----------------+
| 2021-06-26 20:01:31.466919 | 2021-06-26 20:01:31.466919 | zone1 | region    |     0 | default_region |
| 2021-06-26 20:01:31.465863 | 2021-06-26 20:01:31.465863 | zone1 | status    |     2 | ACTIVE         |
| 2021-06-26 20:01:31.466919 | 2021-06-26 20:01:31.466919 | zone1 | zone_type |     0 | ReadWrite      |
+----------------------------+----------------------------+-------+-----------+-------+----------------+
3 rows in set (0.00 sec)MySQL [oceanbase]> alter system add zone 'zone2' region 'default_region';
Query OK, 0 rows affected (0.01 sec)MySQL [oceanbase]> alter system add zone 'zone3' region 'default_region';
Query OK, 0 rows affected (0.00 sec)MySQL [oceanbase]> alter system start zone 'zone2';
Query OK, 0 rows affected (0.00 sec)MySQL [oceanbase]> alter system start zone 'zone3';
Query OK, 0 rows affected (0.00 sec)MySQL [oceanbase]> select * from __all_zone where name in ('region','status','zone_type');
+----------------------------+----------------------------+-------+-----------+-------+----------------+
| gmt_create                 | gmt_modified               | zone  | name      | value | info           |
+----------------------------+----------------------------+-------+-----------+-------+----------------+
| 2021-06-26 20:01:31.466919 | 2021-06-26 20:01:31.466919 | zone1 | region    |     0 | default_region |
| 2021-06-26 20:01:31.465863 | 2021-06-26 20:01:31.465863 | zone1 | status    |     2 | ACTIVE         |
| 2021-06-26 20:01:31.466919 | 2021-06-26 20:01:31.466919 | zone1 | zone_type |     0 | ReadWrite      |
| 2021-06-26 20:07:15.488710 | 2021-06-26 20:07:15.488710 | zone2 | region    |     0 | default_region |
| 2021-06-26 20:07:15.488508 | 2021-06-26 20:08:31.962846 | zone2 | status    |     2 | ACTIVE         |
| 2021-06-26 20:07:15.489765 | 2021-06-26 20:07:15.489765 | zone2 | zone_type |     0 | LOCAL          |
| 2021-06-26 20:07:20.821128 | 2021-06-26 20:07:20.821128 | zone3 | region    |     0 | default_region |
| 2021-06-26 20:07:20.820098 | 2021-06-26 20:08:34.522818 | zone3 | status    |     2 | ACTIVE         |
| 2021-06-26 20:07:20.821128 | 2021-06-26 20:07:20.821128 | zone3 | zone_type |     0 | LOCAL          |
+----------------------------+----------------------------+-------+-----------+-------+----------------+
9 rows in set (0.00 sec)MySQL [oceanbase]> alter system add server '172.20.249.39:3882' zone 'zone2';
Query OK, 0 rows affected (0.01 sec)MySQL [oceanbase]> alter system add server '172.20.249.39:4882' zone 'zone3';
Query OK, 0 rows affected (0.01 sec)select a.zone,concat(a.svr_ip,':',a.svr_port) observer, cpu_total, (cpu_total-cpu_assigned) cpu_free, round(mem_total/1024/1024/1024) mem_total_gb, round((mem_total-mem_assigned)/1024/1024/1024) mem_free_gb, usec_to_time(b.last_offline_time) last_offline_time, usec_to_time(b.start_service_time) start_service_time, b.status, b.build_version , usec_to_time(a.stop_time) stop_time
from __all_virtual_server_stat a join __all_server b on (a.svr_ip=b.svr_ip and a.svr_port=b.svr_port)
order by a.zone, a.svr_ip
;+-------+--------------------+-----------+----------+--------------+-------------+----------------------------+----------------------------+--------+-------------------------------+----------------------------+
| zone  | observer           | cpu_total | cpu_free | mem_total_gb | mem_free_gb | last_offline_time          | start_service_time         | status | build_version                 | stop_time                  |
+-------+--------------------+-----------+----------+--------------+-------------+----------------------------+----------------------------+--------+-------------------------------+----------------------------+
| zone1 | 172.20.249.39:2882 |        14 |        1 |            4 |           1 | 1970-01-01 08:00:00.000000 | 2021-06-26 20:01:32.824604 | active | 3.1.0_-(May 30 2021 11:21:29) | 1970-01-01 08:00:00.000000 |
| zone2 | 172.20.249.39:3882 |        14 |       14 |            4 |           4 | 1970-01-01 08:00:00.000000 | 2021-06-26 20:01:35.617217 | active | 3.1.0_-(May 30 2021 11:21:29) | 1970-01-01 08:00:00.000000 |
| zone3 | 172.20.249.39:4882 |        14 |       14 |            4 |           4 | 1970-01-01 08:00:00.000000 | 2021-06-26 20:09:21.226741 | active | 3.1.0_-(May 30 2021 11:21:29) | 1970-01-01 08:00:00.000000 |
+-------+--------------------+-----------+----------+--------------+-------------+----------------------------+----------------------------+--------+-------------------------------+----------------------------+
3 rows in set (0.00 sec)MySQL [oceanbase]> CREATE resource pool pool_mysql_01b unit = 'my_unit_config', unit_num = 1, zone_list=('zone2','zone3');
Query OK, 0 rows affected (0.01 sec)MySQL [oceanbase]> CREATE resource pool pool_mysql_02b unit = 'my_unit_config', unit_num = 1, zone_list=('zone2','zone3');
Query OK, 0 rows affected (0.01 sec)MySQL [oceanbase]> alter tenant mysql01 resource_pool_list=('pool_mysql_01','pool_mysql_01b');
Query OK, 0 rows affected (0.03 sec)MySQL [oceanbase]> alter tenant mysql01 locality='FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3';
ERROR 4179 (HY000): violate locality principal not allowed
MySQL [oceanbase]> alter tenant mysql01 primary_zone='zone1';
Query OK, 0 rows affected (0.02 sec)MySQL [oceanbase]> alter tenant mysql01 locality='FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3';
ERROR 4179 (HY000): violate locality principal not allowed
MySQL [oceanbase]> alter tenant mysql01 locality='FULL{1}@zone1, FULL{1}@zone2';
Query OK, 0 rows affected (0.02 sec)MySQL [oceanbase]> alter tenant mysql01 locality='FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3';
ERROR 4179 (HY000): alter tenant locality when previous operation is in progress not allowedMySQL [oceanbase]> select gmt_create,gmt_modified,job_id,job_type,job_status,return_code,progress,tenant_id from __all_rootservice_job;
+----------------------------+----------------------------+--------+-----------------------+------------+-------------+----------+-----------+
| gmt_create                 | gmt_modified               | job_id | job_type              | job_status | return_code | progress | tenant_id |
+----------------------------+----------------------------+--------+-----------------------+------------+-------------+----------+-----------+
| 2021-06-26 20:12:54.409071 | 2021-06-26 20:13:25.724652 |      1 | ALTER_TENANT_LOCALITY | SUCCESS    |           0 |      100 |      1001 |
+----------------------------+----------------------------+--------+-----------------------+------------+-------------+----------+-----------+
1 row in set (0.01 sec)MySQL [oceanbase]> CREATE resource pool sys_poolb unit = 'sys_unit_config', unit_num = 1, zone_list=('zone2','zone3');
Query OK, 0 rows affected (0.01 sec)MySQL [oceanbase]> alter tenant sys resource_pool_list=('sys_pool','sys_poolb');
Query OK, 0 rows affected (0.02 sec)MySQL [oceanbase]> alter tenant sys locality='FULL{1}@zone1, FULL{1}@zone2';
Query OK, 0 rows affected (0.02 sec)MySQL [oceanbase]> alter tenant sys locality='FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3';
ERROR 4179 (HY000): alter tenant locality when previous operation is in progress not allowedMySQL [oceanbase]> select gmt_create,gmt_modified,job_id,job_type,job_status,return_code,progress,tenant_id from __all_rootservice_job;
+----------------------------+----------------------------+--------+-----------------------+------------+-------------+----------+-----------+
| gmt_create                 | gmt_modified               | job_id | job_type              | job_status | return_code | progress | tenant_id |
+----------------------------+----------------------------+--------+-----------------------+------------+-------------+----------+-----------+
| 2021-06-26 20:12:54.409071 | 2021-06-26 20:13:25.724652 |      1 | ALTER_TENANT_LOCALITY | SUCCESS    |           0 |      100 |      1001 |
| 2021-06-26 20:15:16.628450 | 2021-06-26 20:15:48.679600 |      2 | ALTER_TENANT_LOCALITY | SUCCESS    |           0 |      100 |      1001 |
| 2021-06-26 20:19:37.365538 | 2021-06-26 20:19:37.365538 |      5 | ALTER_TENANT_LOCALITY | INPROGRESS |        NULL |        0 |         1 |
+----------------------------+----------------------------+--------+-----------------------+------------+-------------+----------+-----------+
5 rows in set (0.00 sec)-- 等若干分钟MySQL [oceanbase]> alter tenant sys locality='FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3';
Query OK, 0 rows affected (0.03 sec)MySQL [oceanbase]> alter tenant mysql02 resource_pool_list=('pool_mysql_02','pool_mysql_02b');
Query OK, 0 rows affected (0.05 sec)MySQL [oceanbase]> alter tenant mysql02 locality='FULL{1}@zone1, FULL{1}@zone2';
Query OK, 0 rows affected (0.02 sec)-- 等若干分钟MySQL [oceanbase]> alter tenant mysql02 locality='FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3';
Query OK, 0 rows affected (0.01 sec)-- 等若干分钟MySQL [oceanbase]> select gmt_create,gmt_modified,job_id,job_type,job_status,return_code,progress,tenant_id from __all_rootservice_job;
+----------------------------+----------------------------+--------+-----------------------+------------+-------------+----------+-----------+
| gmt_create                 | gmt_modified               | job_id | job_type              | job_status | return_code | progress | tenant_id |
+----------------------------+----------------------------+--------+-----------------------+------------+-------------+----------+-----------+
| 2021-06-26 20:12:54.409071 | 2021-06-26 20:13:25.724652 |      1 | ALTER_TENANT_LOCALITY | SUCCESS    |           0 |      100 |      1001 |
| 2021-06-26 20:15:16.628450 | 2021-06-26 20:15:48.679600 |      2 | ALTER_TENANT_LOCALITY | SUCCESS    |           0 |      100 |      1001 |
| 2021-06-26 20:19:37.365538 | 2021-06-26 20:23:15.879598 |      5 | ALTER_TENANT_LOCALITY | SUCCESS    |           0 |      100 |         1 |
| 2021-06-26 20:23:24.097481 | 2021-06-26 20:23:40.449128 |      6 | ALTER_TENANT_LOCALITY | SUCCESS    |           0 |      100 |      1002 |
| 2021-06-26 20:23:42.709761 | 2021-06-26 20:26:18.419506 |      7 | ALTER_TENANT_LOCALITY | SUCCESS    |           0 |      100 |         1 |
| 2021-06-26 20:24:13.183605 | 2021-06-26 20:26:33.958669 |      8 | ALTER_TENANT_LOCALITY | SUCCESS    |           0 |      100 |      1002 |
+----------------------------+----------------------------+--------+-----------------------+------------+-------------+----------+-----------+
8 rows in set (0.01 sec)

这里面信息量非常大,简单说明一下:

1. 先add zone ,要逐个加,然后是逐个 start zone 。

2. 再add server,要指定 节点监听端口和zone,这个跟节点启动进程参数要对应。如果报错,说明没对上。

3. 再给各个租户补充资源池里资源单元。create resource pool 可以指定 zone_list。然后 alter tenant resource_pool_list 指定资源池。一个租户在每个zone只能有一个资源池,但是在不同zone可以有多个资源池。

4. 修改租户的locality属性。做之前,先设置明确的primary_zone(不要random)。修改locality必须缓慢的从一个zone到两个zone,这期间后台会做数据补副本操作,根据实际数据量需要点时间。结束了才能做两个zone到三个zone的扩容。

OB的扩容命令就是这么简单。

最后检查一下扩容结果。

select t1.name resource_pool_name, t2.`name` unit_config_name, t2.max_cpu, t2.min_cpu, round(t2.max_memory/1024/1024/1024) max_mem_gb, round(t2.min_memory/1024/1024/1024) min_mem_gb, t3.unit_id, t3.zone, concat(t3.svr_ip,':',t3.`svr_port`) observer,t4.tenant_id, t4.tenant_name
from __all_resource_pool t1 join __all_unit_config t2 on (t1.unit_config_id=t2.unit_config_id)join __all_unit t3 on (t1.`resource_pool_id` = t3.`resource_pool_id`)left join __all_tenant t4 on (t1.tenant_id=t4.tenant_id)
order by t4.tenant_id, t1.`resource_pool_id`, t2.`unit_config_id`, t3.unit_id
;+--------------------+------------------+---------+---------+------------+------------+---------+-------+--------------------+-----------+-------------+
| resource_pool_name | unit_config_name | max_cpu | min_cpu | max_mem_gb | min_mem_gb | unit_id | zone  | observer           | tenant_id | tenant_name |
+--------------------+------------------+---------+---------+------------+------------+---------+-------+--------------------+-----------+-------------+
| sys_pool           | sys_unit_config  |       5 |       5 |          1 |          1 |       1 | zone1 | 172.20.249.39:2882 |         1 | sys         |
| sys_poolb          | sys_unit_config  |       5 |       5 |          1 |          1 |    1007 | zone2 | 172.20.249.39:3882 |         1 | sys         |
| sys_poolb          | sys_unit_config  |       5 |       5 |          1 |          1 |    1008 | zone3 | 172.20.249.39:4882 |         1 | sys         |
| pool_mysql_01      | my_unit_config   |       4 |       4 |          1 |          1 |    1001 | zone1 | 172.20.249.39:2882 |      1001 | mysql01     |
| pool_mysql_01b     | my_unit_config   |       4 |       4 |          1 |          1 |    1003 | zone2 | 172.20.249.39:3882 |      1001 | mysql01     |
| pool_mysql_01b     | my_unit_config   |       4 |       4 |          1 |          1 |    1004 | zone3 | 172.20.249.39:4882 |      1001 | mysql01     |
| pool_mysql_02      | my_unit_config   |       4 |       4 |          1 |          1 |    1002 | zone1 | 172.20.249.39:2882 |      1002 | mysql02     |
| pool_mysql_02b     | my_unit_config   |       4 |       4 |          1 |          1 |    1005 | zone2 | 172.20.249.39:3882 |      1002 | mysql02     |
| pool_mysql_02b     | my_unit_config   |       4 |       4 |          1 |          1 |    1006 | zone3 | 172.20.249.39:4882 |      1002 | mysql02     |
+--------------------+------------------+---------+---------+------------+------------+---------+-------+--------------------+-----------+-------------+
9 rows in set (0.00 sec)

特别介绍:obproxy部署。

obproxy的部署方法跟早期文章里写的方法有点变化了。

首先,obproxy跟OB集群通信是使用sys租户内的一个内部账户proxyro。这个账户需要创建。

[admin@obpilot obproxy]$ mysql -h127.1 -uroot@sys -P2881 -p123456 -c -A oceanbaseMySQL [oceanbase]> create user proxyro identified by 'proxyro123456';
Query OK, 0 rows affected (0.01 sec)MySQL [oceanbase]> grant select on oceanbase.* to proxyro;
Query OK, 0 rows affected (0.02 sec)

然后开始启动obproxy。

mkdir -p /data/obproxy
cd /data/obproxy && /home/admin/obproxy-3.1.0/bin/obproxy -p2883 -c obcluster -r "172.20.249.39:2881;172.20.249.39:3881;172.20.249.39:4881" -o "enable_cluster_checkout=false,enable_strict_kernel_release=false,enable_metadb_used=false"mysql -h127.1 -uroot@proxysys -P2883 -pMySQL [(none)]> alter proxyconfig set obproxy_sys_password='proxysys123456';
Query OK, 0 rows affected (0.00 sec)MySQL [(none)]> alter proxyconfig set observer_sys_password='proxyro123456';
Query OK, 0 rows affected (0.00 sec)MySQL [(none)]> show proxyconfig like '%sys_password%';
+-----------------------+------------------------------------------+--------------------------------+-------------+---------------+
| name                  | value                                    | info                           | need_reboot | visible_level |
+-----------------------+------------------------------------------+--------------------------------+-------------+---------------+
| observer_sys_password | dcb332deaee8b0030c3fd21a8e9f2813984339ea | password for observer sys user | false       | SYS           |
| obproxy_sys_password  | 3a8d187554571d6be2b27749187dcb8ca6285ede | password for obproxy sys user  | false       | SYS           |
+-----------------------+------------------------------------------+--------------------------------+-------------+---------------+
2 rows in set (0.00 sec)[admin@obpilot obproxy]$ mysql -h127.1 -uroot@sys#obcluster -P2883 -p123456 -c -A oceanbaseMySQL [oceanbase]> show full processlist;
+------------+---------+--------+---------------------+-----------+---------+------+--------+-----------------------+---------------+------+--------------+
| Id         | User    | Tenant | Host                | db        | Command | Time | State  | Info                  | Ip            | Port | Proxy_sessid |
+------------+---------+--------+---------------------+-----------+---------+------+--------+-----------------------+---------------+------+--------------+
| 3221633341 | root    | sys    | 172.20.249.39:41650 | oceanbase | Query   |    0 | ACTIVE | show full processlist | 172.20.249.39 | 2881 |            2 |
| 3221749764 | proxyro | sys    | 172.20.249.39:32942 | oceanbase | Sleep   |    6 | SLEEP  | NULL                  | 172.20.249.39 | 3881 |            3 |
+------------+---------+--------+---------------------+-----------+---------+------+--------+-----------------------+---------------+------+--------------+
2 rows in set (0.01 sec)

说明:

1. -r 是指定OB集群的rootservice_list 地址,因为OB已经扩容为三副本里,所以这里会有三个地址(ip:port,port使用连接端口)。

2. 给obproxy指定一个启动目录 /data/obproxy。这个可以改。如果启动多个obproxy进程,就设置多个目录。同样,obproxy运行在admin用户下。多个obproxy就要设置不同的监听端口。默认是2883.

3. obproxy启动后,默认用 root@proxysys 登录,密码为空。需要改密码(通过proxy参数obproxy_sys_password指定)。

4. obproxy启动后,还需要修改proxyro的密码(通过proxy参数observer_sys_password指定),设置为跟OB集群里创建的proxyro密码一致才能链接那个OB集群。

测试一下这个obproxy。

[admin@obpilot obproxy]$ mysql -h127.1 -uroot@sys#obcluster -P2883 -p123456 -c -A oceanbase
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.6.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 [oceanbase]> select * from __all_server;
+----------------------------+----------------------------+---------------+----------+----+-------+------------+-----------------+--------+-----------------------+-------------------------------+-----------+--------------------+--------------+----------------+-------------------+
| gmt_create                 | gmt_modified               | svr_ip        | svr_port | id | zone  | inner_port | with_rootserver | status | block_migrate_in_time | build_version                 | stop_time | start_service_time | first_sessid | with_partition | last_offline_time |
+----------------------------+----------------------------+---------------+----------+----+-------+------------+-----------------+--------+-----------------------+-------------------------------+-----------+--------------------+--------------+----------------+-------------------+
| 2021-06-26 20:01:24.753198 | 2021-06-26 20:01:33.821660 | 172.20.249.39 |     2882 |  1 | zone1 |       2881 |               1 | active |                     0 | 3.1.0_-(May 30 2021 11:21:29) |         0 |   1624708892824604 |            0 |              1 |                 0 |
| 2021-06-26 20:09:02.347295 | 2021-06-26 20:12:54.900390 | 172.20.249.39 |     3882 |  2 | zone2 |       3881 |               0 | active |                     0 | 3.1.0_-(May 30 2021 11:21:29) |         0 |   1624708895617217 |            0 |              1 |                 0 |
| 2021-06-26 20:09:10.246956 | 2021-06-26 20:15:17.112561 | 172.20.249.39 |     4882 |  3 | zone3 |       4881 |               0 | active |                     0 | 3.1.0_-(May 30 2021 11:21:29) |         0 |   1624709361226741 |            0 |              1 |                 0 |
+----------------------------+----------------------------+---------------+----------+----+-------+------------+-----------------+--------+-----------------------+-------------------------------+-----------+--------------------+--------------+----------------+-------------------+
3 rows in set (0.02 sec)MySQL [oceanbase]> show full processlist;
+------------+---------+--------+---------------------+-----------+---------+------+--------+-----------------------+---------------+------+--------------+
| Id         | User    | Tenant | Host                | db        | Command | Time | State  | Info                  | Ip            | Port | Proxy_sessid |
+------------+---------+--------+---------------------+-----------+---------+------+--------+-----------------------+---------------+------+--------------+
| 3222011908 | root    | sys    | 172.20.249.39:60006 | oceanbase | Sleep   |   19 | SLEEP  | NULL                  | 172.20.249.39 | 4881 |            4 |
| 3221749764 | proxyro | sys    | 172.20.249.39:32942 | oceanbase | Sleep   |    6 | SLEEP  | NULL                  | 172.20.249.39 | 3881 |            3 |
| 3221649264 | root    | sys    | 172.20.249.39:41704 | oceanbase | Query   |    0 | ACTIVE | show full processlist | 172.20.249.39 | 2881 |            4 |
+------------+---------+--------+---------------------+-----------+---------+------+--------+-----------------------+---------------+------+--------------+
3 rows in set (0.01 sec)MySQL [oceanbase]>

至此,obproxy安装成功。

特别介绍:OB三副本直接部署。

上面可能会有人误解为OB安装需要从单副本开始,再扩容到三副本。这里再提供一下三副本的直接安装方法。

首先彻底清理掉已安装的OB和OBPROXY。

kill -9 `pidof observer` `pidof obproxy`
sleep 3
/bin/rm -rf /data/observer{01,02,03} /data/obproxy

开始启动三个OB节点进程。

mkdir -p /data/{observer01,observer02,observer03,obproxy}
mkdir -p /data/observer{01,02,03}/store/{sort_dir,sstable,clog,ilog,slog}cd /data/observer01/ && /home/admin/oceanbase/bin/observer -r "172.20.249.39:2882:2881;172.20.249.39:3882:3881;172.20.249.39:4882:4881" -o __min_full_resource_pool_memory=268435456,memory_limit=8G,system_memory=4G,stack_size=512K,cpu_count=16,cache_wash_threshold=1G,workers_per_cpu_quota=10,schema_history_expire_time=1d,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_size=50G,enable_syslog_recycle=True,max_syslog_file_count=10 -z zone1 -p 2881 -P 2882 -c 1 -d /data/observer01/store -i eth0 -l INFOcd /data/observer02/ && /home/admin/oceanbase/bin/observer -r "172.20.249.39:2882:2881;172.20.249.39:3882:3881;172.20.249.39:4882:4881" -o __min_full_resource_pool_memory=268435456,memory_limit=8G,system_memory=4G,stack_size=512K,cpu_count=16,cache_wash_threshold=1G,workers_per_cpu_quota=10,schema_history_expire_time=1d,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_size=50G,enable_syslog_recycle=True,max_syslog_file_count=10 -z zone2 -p 3881 -P 3882 -c 1 -d /data/observer02/store -i eth0 -l INFOcd /data/observer03/ && /home/admin/oceanbase/bin/observer -r "172.20.249.39:2882:2881;172.20.249.39:3882:3881;172.20.249.39:4882:4881" -o __min_full_resource_pool_memory=268435456,memory_limit=8G,system_memory=4G,stack_size=512K,cpu_count=16,cache_wash_threshold=1G,workers_per_cpu_quota=10,schema_history_expire_time=1d,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_size=50G,enable_syslog_recycle=True,max_syslog_file_count=10 -z zone3 -p 4881 -P 4882 -c 1 -d /data/observer03/store -i eth0 -l INFO

一样的,检查三个进程都监听成功。

[admin@obpilot observer03]$ ps -ef|grep observer |grep -v grep
admin    21194     1 89 13:51 ?        00:04:20 /home/admin/oceanbase/bin/observer -r 172.20.249.39:2882:2881;172.20.249.39:3882:3881;172.20.249.39:4882:4881 -o __min_full_resource_pool_memory=268435456,memory_limit=8G,system_memory=4G,stack_size=512K,cpu_count=16,cache_wash_threshold=1G,workers_per_cpu_quota=10,schema_history_expire_time=1d,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_size=50G,enable_syslog_recycle=True,max_syslog_file_count=10 -z zone1 -p 2881 -P 2882 -c 1 -d /data/observer01/store -i eth0 -l INFO
admin    21775     1 82 13:52 ?        00:03:47 /home/admin/oceanbase/bin/observer -r 172.20.249.39:2882:2881;172.20.249.39:3882:3881;172.20.249.39:4882:4881 -o __min_full_resource_pool_memory=268435456,memory_limit=8G,system_memory=4G,stack_size=512K,cpu_count=16,cache_wash_threshold=1G,workers_per_cpu_quota=10,schema_history_expire_time=1d,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_size=50G,enable_syslog_recycle=True,max_syslog_file_count=10 -z zone2 -p 3881 -P 3882 -c 1 -d /data/observer02/store -i eth0 -l INFO
admin    22371     1 86 13:52 ?        00:03:32 /home/admin/oceanbase/bin/observer -r 172.20.249.39:2882:2881;172.20.249.39:3882:3881;172.20.249.39:4882:4881 -o __min_full_resource_pool_memory=268435456,memory_limit=8G,system_memory=4G,stack_size=512K,cpu_count=16,cache_wash_threshold=1G,workers_per_cpu_quota=10,schema_history_expire_time=1d,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_size=50G,enable_syslog_recycle=True,max_syslog_file_count=10 -z zone3 -p 4881 -P 4882 -c 1 -d /data/observer03/store -i eth0 -l INFO
[admin@obpilot observer03]$ netstat -ntlp
(Not all processes could be identified, non-owned process infowill 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:3881            0.0.0.0:*               LISTEN      21775/observer
tcp        0      0 0.0.0.0:3882            0.0.0.0:*               LISTEN      21775/observer
tcp        0      0 0.0.0.0:4881            0.0.0.0:*               LISTEN      22371/observer
tcp        0      0 0.0.0.0:4882            0.0.0.0:*               LISTEN      22371/observer
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:2881            0.0.0.0:*               LISTEN      21194/observer
tcp        0      0 0.0.0.0:2882            0.0.0.0:*               LISTEN      21194/observer
[admin@obpilot observer03]$

修改几个账户密码

mysql -h172.20.249.39 -uroot -P2881 -p -c -Aset session ob_query_timeout=1000000000; alter system bootstrap ZONE 'zone1' SERVER '172.20.249.39:2882' , ZONE 'zone2' SERVER '172.20.249.39:3882' , ZONE 'zone3' SERVER '172.20.249.39:4882';alter user root identified by '123456';
create user proxyro identified by 'proxyro123456';

安装obproxy的方法同上。obproxy启动时指定 rootservice_list写死这个地址不是很灵活。在企业版里,OB会把rootservice_list地址通过OCP API保存到元数据库里。

最后说一些常见问题解答。

1. observer.log 比较难懂,找你看得懂的ERROR日志。或者根据错误号到官网查看说明。总会找到有用的线索。看得懂源码的朋友例外。

2. 部署是一定能成功的,不成功就是某一个细节没做好。看上面步骤细节并不多。此外机器内存一定要8G以上。

3. 不管是官网部署的还是上面方法部署的OB,就是玩玩。可以跑性能看看,但不要作为评估的结论。毕竟用好OB之前至少得先确保熟悉原理和性能调优方法。可以看看本公众号的一些文章总结。(公众号搜索:OceanBase技术闲谈)。

自研很辛苦,开源要勇气,数据库学问很深,多测试多提意见,多鼓励少讽刺。相信OB社区版会发展的更好!

有问题欢迎进 OB 钉钉群讨论。钉钉群号:32725302 33254054

OceanBase 社区版部署示例相关推荐

  1. 教程直播第8期|一文详解 OceanBase 社区版生态工具 ODP OCP

    在 OceanBase 生态大家庭中,除了 OceanBase 数据库内核部分,还有很多功能强大的周边工具,这些工具实现了不同的功能,满足了客户多样化的需求.本文将介绍两个极具代表性的的生态工具,帮助 ...

  2. 封仲淹:OceanBase社区版4.0未来畅想

    8 月 10 日,2022 OceanBase 年度发布会在京沪深三地同时召开,OceanBase 资深开源生态技术总监封仲淹在会上分享了<OceanBase 社区版 4.0 未来畅想>的 ...

  3. Navicat!OceanBase社区版新朋友来啦!

    引言: 近期,Navicat Premium 16.1与Navicat for MySQL 16.1版本,将新增 OceanBase 社区版兼容功能,为用户在使用 OceanBase 社区版迁移过程中 ...

  4. 数据3分钟丨Snowflake获“2021 DBMS”;OceanBase社区版3.1.2正式发布

    数据 3 分钟 由 ACDU (中国 DBA 联盟) 与墨天轮联合出品的全新视频节目上线啦-三分钟带你来了解数据行业动态,节目内容主要包含数据行业最新的产品发布.公司大事件.行业新闻等. 本期内容概览 ...

  5. OceanBase 社区版下载部署指引

    OceanBase在2021年6月1日公布了社区版(官网:open.oceanbase.com).立即有很多网友开始下载使用.部分朋友在安装部署上不是很顺利,本文主要是提供一种社区版安装方法,让大家了 ...

  6. 一文讲透|如何部署OceanBase社区版(4.x版)

    欢迎访问 OceanBase 官网获取更多信息:https://www.oceanbase.com/ 作者简介: 孙宏鑫,OceanBase技术专家,主要负责oceanbase开源生态,运维监控相关工 ...

  7. onlyoffice docs 社区版部署(centos版)--使用于onlyoffice二次开发

    安装适用于CentOS及其衍生产品的ONLYOFFICE Docs社区版 介绍 功能性 系统要求 安装Nginx 软件包安装 修改nginx配置 安装EPEL储存库 安装和配置PostgreSQL 安 ...

  8. DZZOffice(大桌子)企业文档协同平台教程系列(三)——ONLYOFFICE社区版部署、配置

    ONLYOFFICE有多种部署方式,本文介绍docker方式的部署 官网地址:https://www.onlyoffice.com/zh/download.aspx 一.安装docker yum up ...

  9. onlyoffice docs 社区版部署(windows版)--使用于onlyoffice二次开发

    介绍 Community Edition允许您在本地服务器上安装ONLYOFFICE Docs,并将在线编辑器与ONLYOFFICE协作平台或其他流行系统集成. ONLYOFFICE Docs是一个在 ...

最新文章

  1. await使用中的阻塞和并发(一)
  2. LUOGU 3089 后缀排序(模板)
  3. python多分类画混淆矩阵_【AI基础】分类器评估一:混淆矩阵、准确率、精确率、召回率、灵敏度、特异度、误诊率、漏诊率...
  4. 【Android】使用Assets目录中的图片资源
  5. MyBatis的框架架构设计是怎么样的?
  6. qt socket 传递结构体 结构体中有list_计算机网络应用--Socket编程实验(二)
  7. Intel 64/x86_64/IA-32/x86处理器 - SIMD指令集 - SSE扩展(11) - 数据可缓存性控制指令
  8. Java开发 - 异常 - 使用throws
  9. php实现C32,c32rtomb - [ C语言中文开发手册 ] - 在线原生手册 - php中文网
  10. 【爷青回系列】使用VMware虚拟机安装Windows XP系统!最详细!
  11. 命令行调用SQL查询分析器
  12. cf英文名字格式好看的_格式好看的cf英语名字【三篇】
  13. Facebook 新一代 React 状态管理库 Recoil
  14. galaxy s8 android pc,三星S8/S8+发布!全面屏、智能助理、秒变PC,苹果8已败
  15. m与n的数字运算python_Python脚本基础运算和算法
  16. 一款Android图文识别与扫描软件
  17. db2数据库(db2数据库安装)
  18. 深度学习领域常用英文表达
  19. 腾讯企业邮箱发件接口返回Recipient address rejected: ERS-RBL.
  20. rapido-bootstrap响应式html后台管理模板,最值得拥有的免费Bootstrap后台管理模板

热门文章

  1. MTA网络基础考试准备指南
  2. Error:python-neutron conflicts with python2-eventlet-0.18.4-1.el7.noarch(安装openstack-neutron出现的问题解决)
  3. 大公司为什么很少招易语言程序员
  4. 电脑小问题:快速恢复bios出厂设置方法
  5. + 实例演练ASP+XML编程(二)
  6. 矿用巷道巡检机器人_防爆巷道巡检机器人
  7. 浪潮编程题python石头排序_数分 | 沙滩排石头-浪潮提前批笔试 Java、C++、Python
  8. java fire forget,响应式协议RSocket介绍
  9. 呼声很高的这门语言真的难学吗?
  10. c语言作业制作仓库管理系统,C语言课程设计 仓库管理系统