当前位置:   article > 正文

OceanBase使用 OBD 自动化部署多节点集群_ob多节点

ob多节点

OceanBase提供多种数据库集群部署方式,之前我也有分享手动部署的方式,通过手工部署方式,可以了解OB集群的运行逻辑并在错误出现时及时手工处理。

今天这篇文章,我们来分享一下如何《使用 OBD 自动化部署多节点集群》。

有关手动部署的步骤及注意事项,请参考如何手动部署 OceanBase集群

1.集群规划

有关集群功能的划分,我们仍然服用之前的规划信息。

1.1 集群角色划分

本次部署 OceanBase 三节点集群,三节点每个节点占用一台服务器部署observer;**另外单独采用一台服务器作为中控机;**通过中控机直接远程登录到 OceanBase 节点上部署启动 observer 进程,并在中控机上部署 obproxy 进程。架构图如下:

在这里插入图片描述

1.2 机器划分

官方建议的机器可用内存最好是8G以上,所以我这里4台机器均分配了10G的虚拟内存。CPU是每个虚拟机2个虚拟核心。它们的角色分配如下:

在这里插入图片描述

有关服务器参数设置、SSH互信设置、时间同步等设置方法,全部参考手动部署的内容即可。

3.使用 OBD 自动化部署多节点集群

3.1 下载并安装OBD

首先如果我们的中控机上没有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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

将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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
[admin@obproxy ~]$ source .bashrc
  • 1

3.2 编写初始化配置文件

根据上面设置的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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68

3.3 执行集群初始化

配置文件准备好后,接下来,需要做的就是一键部署集群了:

您可使用命令 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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17

部署完成后,可以通过如下命令检查集群部署状态:

[admin@obproxy ~]$ obd cluster list
+----------------------------------------------------------------+
|                          Cluster List                          |
+----------+-----------------------------------+-----------------+
| Name     | Configuration Path                | Status (Cached) |
+----------+-----------------------------------+-----------------+
| ob-chris | /home/admin/.obd/cluster/ob-chris | deployed        |
+----------+-----------------------------------+-----------------+
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

3.4 启动集群并自举

采用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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46

通过上面的日志记录可以看到,obd集群启动和自举属于自动操作,基本不需要干预。

3.5 连接集群查看

在执行完上面的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]>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

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
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

这里还需要注意两点:
1.如果你有看官网的登录选项,会看到在租户后面增加了集群名称,默认情况下,在服务器上直接登录需要去掉,否则会报 access denied 错误;
2.我这里配置文件有设置密码,所以登录的时候采用 -proot 将密码传了进去,如果你的密码不一样,请自行修改。

4.写在最后

至此为止,obd部署OceanBase集群的分享结束,欢迎大家添加博主交流。

最后,如果觉得文章对您有帮助,请给博主点赞、收藏、关注,博主会不断推出更多优质的文章。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/168060
推荐阅读
相关标签
  

闽ICP备14008679号