赞
踩
OceanBase提供多种数据库集群部署方式,之前我也有分享手动部署的方式,通过手工部署方式,可以了解OB集群的运行逻辑并在错误出现时及时手工处理。
今天这篇文章,我们来分享一下如何《使用 OBD 自动化部署多节点集群》。
有关手动部署的步骤及注意事项,请参考如何手动部署 OceanBase集群 。
有关集群功能的划分,我们仍然服用之前的规划信息。
本次部署 OceanBase 三节点集群,三节点每个节点占用一台服务器部署observer;**另外单独采用一台服务器作为中控机;**通过中控机直接远程登录到 OceanBase 节点上部署启动 observer 进程,并在中控机上部署 obproxy 进程。架构图如下:
官方建议的机器可用内存最好是8G以上,所以我这里4台机器均分配了10G的虚拟内存。CPU是每个虚拟机2个虚拟核心。它们的角色分配如下:
有关服务器参数设置、SSH互信设置、时间同步等设置方法,全部参考手动部署的内容即可。
首先如果我们的中控机上没有obd软件,我们需要先从官网下载并安装:
下载完成后,rpm一键安装即可:
[admin@obproxy ~]$ sudo rpm -ivh ob-deploy-1.3.0-8.el7.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:ob-deploy-1.3.0-8.el7 ################################# [100%]
Installation of obd finished successfully
Please source /etc/profile.d/obd.sh to enable it
将obd.sh配置到.bashrc并生效
[admin@obproxy ~]$ cat .bashrc
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=
# User specific aliases and functionsi
source /etc/profile.d/obd.sh
[admin@obproxy ~]$ source .bashrc
根据上面设置的IP和主机功能,我在中控机上创建了如下的初始化配置文件:
[admin@obproxy ~]$ cat init.yaml user: username: admin password: admin oceanbase-ce: servers: - name: server1 ip: 10.211.55.55 - name: server2 ip: 10.211.55.56 - name: server3 ip: 10.211.55.57 global: devname: eth0 cluster_id: 1 memory_limit: 8G system_memory: 4G stack_size: 512K cpu_count: 12 cache_wash_threshold: 1G __min_full_resource_pool_memory: 268435456 workers_per_cpu_quota: 10 schema_history_expire_time: 1d net_thread_count: 4 major_freeze_duty_time: Disable minor_freeze_times: 10 enable_separate_sys_clog: 0 enable_merge_by_turn: FALSE datafile_disk_percentage: 20 syslog_level: INFO enable_syslog_wf: false enable_syslog_recycle: true max_syslog_file_count: 4 root_password: root proxyro_password: proxyro server1: mysql_port: 2881 rpc_port: 2882 home_path: /home/admin/observer data_dir: /data zone: zone1 server2: mysql_port: 2881 rpc_port: 2882 home_path: /home/admin/observer data_dir: /data zone: zone2 server3: mysql_port: 2881 rpc_port: 2882 home_path: /home/admin/observer data_dir: /data zone: zone3 obproxy: depends: - oceanbase-ce servers: - 10.211.55.54 global: listen_port: 2883 prometheus_listen_port: 2884 home_path: /home/admin/obproxy enable_cluster_checkout: false skip_proxy_sys_private_check: true obproxy_sys_password: sys observer_sys_password: proxyro
配置文件准备好后,接下来,需要做的就是一键部署集群了:
您可使用命令 obd cluster deploy [集群名] -c 集群配置文件 进行部署。
[admin@obproxy ~]$ obd cluster deploy ob-chris -c init.yaml oceanbase-ce-3.1.3 already installed. +-------------------------------------------------------------------------------------------+ | Packages | +--------------+---------+-----------------------+------------------------------------------+ | Repository | Version | Release | Md5 | +--------------+---------+-----------------------+------------------------------------------+ | oceanbase-ce | 3.1.3 | 10000292022032916.el7 | eab08e5d473bd4884fdf2ac4d7dff6a329b68abe | +--------------+---------+-----------------------+------------------------------------------+ Repository integrity check ok Parameter check ok Open ssh connection ok Remote oceanbase-ce-3.1.3-eab08e5d473bd4884fdf2ac4d7dff6a329b68abe repository install ok Remote oceanbase-ce-3.1.3-eab08e5d473bd4884fdf2ac4d7dff6a329b68abe repository lib check ok Cluster status check ok Initializes observer work home ok ob-chris deployed
部署完成后,可以通过如下命令检查集群部署状态:
[admin@obproxy ~]$ obd cluster list
+----------------------------------------------------------------+
| Cluster List |
+----------+-----------------------------------+-----------------+
| Name | Configuration Path | Status (Cached) |
+----------+-----------------------------------+-----------------+
| ob-chris | /home/admin/.obd/cluster/ob-chris | deployed |
+----------+-----------------------------------+-----------------+
采用obd命令,启动集群和自举一气呵成:
[admin@obproxy ~]$ obd cluster list +----------------------------------------------------------------+ | Cluster List | +----------+-----------------------------------+-----------------+ | Name | Configuration Path | Status (Cached) | +----------+-----------------------------------+-----------------+ | ob-chris | /home/admin/.obd/cluster/ob-chris | deployed | +----------+-----------------------------------+-----------------+ [admin@obproxy ~]$ obd cluster start ob-chris Get local repositories and plugins ok Open ssh connection ok Load cluster param plugin ok Check before start observer ok [WARN] (10.211.55.55) clog and data use the same disk (/) [WARN] (10.211.55.56) clog and data use the same disk (/) [WARN] (10.211.55.57) clog and data use the same disk (/) Check before start obproxy ok 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 | +--------------+---------+------+-------+--------+ | 10.211.55.55 | 3.1.3 | 2881 | zone1 | active | | 10.211.55.56 | 3.1.3 | 2881 | zone2 | active | | 10.211.55.57 | 3.1.3 | 2881 | zone3 | active | +--------------+---------+------+-------+--------+ Start obproxy ok obproxy program health check ok Connect to obproxy ok Initialize cluster +------------------------------------------------+ | obproxy | +--------------+------+-----------------+--------+ | ip | port | prometheus_port | status | +--------------+------+-----------------+--------+ | 10.211.55.54 | 2883 | 2884 | active | +--------------+------+-----------------+--------+ ob-chris running
通过上面的日志记录可以看到,obd集群启动和自举属于自动操作,基本不需要干预。
在执行完上面的N个步骤后,OB的服务组件均已经启动起来了,这里启动了一个单obproxy+3 observer的集群,下面我们尝试使用mysql/obclient客户端登录:
MySQL客户端登录:
[admin@obproxy ~]$ mysql -h 10.211.55.54 -uroot@sys -P2883 -proot -c -A oceanbase
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 2097153
Server version: 5.6.25 OceanBase 3.1.3 (r10000292022032916-3d79cacb37012cf61b7cb8faf00d9a6bb152bcd1) (Built Mar 29 2022 08:20:39)
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]>
obclient客户端登录:
[admin@observer1 ~]$ obclient -h 10.211.55.54 -uroot@sys -P2883 -proot -c -A oceanbase
Welcome to the OceanBase. Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 5.6.25 OceanBase 3.1.3 (r10000292022032916-3d79cacb37012cf61b7cb8faf00d9a6bb152bcd1) (Built Mar 29 2022 08:20:39)
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]>
这里还需要注意两点:
1.如果你有看官网的登录选项,会看到在租户后面增加了集群名称,默认情况下,在服务器上直接登录需要去掉,否则会报access denied
错误;
2.我这里配置文件有设置密码,所以登录的时候采用-proot
将密码传了进去,如果你的密码不一样,请自行修改。
至此为止,obd部署OceanBase集群的分享结束,欢迎大家添加博主交流。
最后,如果觉得文章对您有帮助,请给博主点赞、收藏、关注,博主会不断推出更多优质的文章。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。