当前位置:   article > 正文

OceanBase学习笔记(一)——使用OBD自动部署多节点集群_obd-2008: cluster clocks are out of sync

obd-2008: cluster clocks are out of sync

部署安排:三副本三节点集群,OBD自动部署

操作系统:Centos7.2

参考官方文档:OceanBase 社区版

1. 部署准备

节点安排:四台阿里云服务器,均为32C64G,其中一台安装OBD自动部署软件,并安装obclient作为客户端,使用该机OBD自动部署三节点集群。

在中控机上安装相关软件:

  1. yum install -y yum-utils
  2. yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo
  3. yum -y install ob-deploy oceanbase obclient

2. 服务器初始化

在四台服务器上,均做如下初始化(必做,否则后续部署集群会报很多错误):

2.1 内核参数修改

执行:

vim /etc/sysctl.conf

将打开的文件内容改为: 

  1. net.core.somaxconn = 2048
  2. net.core.netdev_max_backlog = 10000
  3. net.core.rmem_default = 16777216
  4. net.core.wmem_default = 16777216
  5. net.core.rmem_max = 16777216
  6. net.core.wmem_max = 16777216
  7. net.ipv4.ip_local_port_range = 3500 65535
  8. net.ipv4.ip_forward = 0
  9. net.ipv4.conf.default.rp_filter = 1
  10. net.ipv4.conf.default.accept_source_route = 0
  11. net.ipv4.tcp_syncookies = 0
  12. net.ipv4.tcp_rmem = 4096 87380 16777216
  13. net.ipv4.tcp_wmem = 4096 65536 16777216
  14. net.ipv4.tcp_max_syn_backlog = 16384
  15. net.ipv4.tcp_fin_timeout = 15
  16. net.ipv4.tcp_max_syn_backlog = 16384
  17. net.ipv4.tcp_tw_reuse = 1
  18. net.ipv4.tcp_tw_recycle = 1
  19. net.ipv4.tcp_slow_start_after_idle=0
  20. vm.swappiness = 0
  21. vm.min_free_kbytes = 2097152
  22. vm.max_map_count=655360
  23. fs.aio-max-nr=1048576

保存并退出后,执行:

sysctl -p

2.2 修改会话变量设置

执行:

vi /etc/security/limits.conf

 在最后加上(前两行可能已经存在,修改数字即可):

  1. * soft nofile 655360
  2. * hard nofile 655360
  3. * soft nproc 655360
  4. * hard nproc 655360
  5. * soft core unlimited
  6. * hard core unlimited
  7. * soft stack unlimited
  8. * hard stack unlimited

 2.3 配置时间同步服务

使用如下代码,判断是否使用ntpd服务:

systemctl status ntpd

如果出现如下结果, 跳到2.4:

Unit ntpd.service could not be found.

否则卸载ntpd:

yum autoremove ntp

安装chrony:

yum -y install chrony

修改chrony配置文件:

vi /etc/chrony.conf

将打开的文件改为:

  1. # server 后面跟时间同步服务器
  2. # 使用 pool.ntp.org 项目中的公共服务器。按 server 配置,理论上您想添加多少时间服务器都可以。
  3. # 或者使用 阿里云的 ntp 服务器
  4. # Please consider joining the pool (http://www.pool.ntp.org/join.html).
  5. server ntp.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst
  6. server ntp.aliyun.com minpoll 4 maxpoll 10 iburst
  7. server ntp1.aliyun.com minpoll 4 maxpoll 10 iburst
  8. server ntp1.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst
  9. server ntp10.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst
  10. # 如果是测试环境,没有时间同步服务器,那就选取一台配置为时间同步服务器。
  11. # 如果选中的是本机,则取消下面 server 注释
  12. #server 127.127.1.0
  13. # 根据实际时间计算出服务器增减时间的比率,然后记录到一个文件中,在系统重启后为系统做出最佳时间补偿调整。
  14. driftfile /var/lib/chrony/drift
  15. # chronyd 根据需求减慢或加速时间调整,
  16. # 在某些情况下系统时钟可能漂移过快,导致时间调整用时过长。
  17. # 该指令强制 chronyd 调整时期,大于某个阀值时步进调整系统时钟。
  18. # 只有在因 chronyd 启动时间超过指定的限制时(可使用负值来禁用限制)没有更多时钟更新时才生效。
  19. makestep 10 3
  20. # 将启用一个内核模式,在该模式中,系统时间每 11 分钟会拷贝到实时时钟(RTC)。
  21. rtcsync
  22. # Enable hardware timestamping on all interfaces that support it.
  23. # 通过使用 hwtimestamp 指令启用硬件时间戳
  24. #hwtimestamp eth0
  25. #hwtimestamp eth1
  26. #hwtimestamp *
  27. # Increase the minimum number of selectable sources required to adjust
  28. # the system clock.
  29. #minsources 2
  30. # 指定一台主机、子网,或者网络以允许或拒绝 NTP 连接到扮演时钟服务器的机器
  31. #allow 192.168.0.0/16
  32. # 即使没有同步到时间源,也要服务时间
  33. local stratum 10
  34. # 指定包含 NTP 验证密钥的文件。
  35. keyfile /etc/chrony.keys
  36. # 指定日志文件的目录。
  37. logdir /var/log/chrony
  38. # Select which information is logged.
  39. #log measurements statistics tracking

对该文件的一些说明

①选择中控机作为时间同步服务器

②第13行,如果此时做中控机初始化,改为:(去掉#即可)

server 127.127.1.0

否则,改为:

server 中控机IP地址

③# 指定一台主机、子网,或者网络以允许或拒绝 NTP 连接到扮演时钟服务器的机器

在这一行下面改为:

  1. allow 第一个节点子网/24
  2. allow 第一个节点子网/24
  3. allow 第一个节点子网/24
  4. 例:
  5. allow 172.28.240.0/24
  6. allow 172.28.137.0/24
  7. allow 172.28.59.0/24

保存退出。

执行命令,使该配置文件生效:

  1. systemctl start chronyd.service
  2. systemctl enable chronyd.service

 检查是否完成时间同步设置,在中控机使用clockdiff查各个节点:

 当delta值为0ms或1ms可基本视为成功,如果还是很大建议多使用clockdiff查几次,如果没有变小,再检查是否出错。

2.4 配置 SSH 免密登录

在中控机执行:

ssh-keygen -t rsa

上面命令会在用户的 HOME 目录中生成文件夹 .ssh 

复制 RSA 或 DSA 公钥到目标节点,打通到三个节点的 SSH 免密登录。

在中控机执行:

  1. ssh-copy-id 用户名@IP地址
  2. 例:
  3. ssh-copy-id root@172.24.280.125
  4. ssh-copy-id root@172.24.280.126
  5. ssh-copy-id root@172.24.280.126

在四台服务器上均做此初始化即可。

3. 部署

3.1准备配置文件

下载配置文件模板:

obdeploy/mini-single-with-obproxy-example.yaml at master · oceanbase/obdeploy · GitHub

修改该配置文件:

  1. ## Only need to configure when remote login is required
  2. user:
  3. username: root
  4. password: 123465
  5. key_file: /root/.ssh/id_rsa.pub
  6. port: your ssh port, default 22
  7. # timeout: ssh connection timeout (second), default 30
  8. oceanbase-ce:
  9. servers:
  10. - name: obce01
  11. # Please don't use hostname, only IP can be supported
  12. ip: 172.17.237.61
  13. - name: obce02
  14. ip: 172.20.126.115
  15. - name: obce03
  16. ip: 172.28.240.128
  17. global:
  18. # Please set devname as the network adaptor's name whose ip is in the setting of severs.
  19. # if set severs as "127.0.0.1", please set devname as "lo"
  20. # if current ip is 192.168.1.10, and the ip's network adaptor's name is "eth0", please use "eth0"
  21. devname: eth0
  22. cluster_id: 1
  23. # please set memory limit to a suitable value which is matching resource.
  24. memory_limit: 8G # The maximum running memory for an observer
  25. system_memory: 4G # The reserved system memory. system_memory is reserved for general tenants. The default value is 30G.
  26. stack_size: 512K
  27. cpu_count: 16
  28. cache_wash_threshold: 1G
  29. __min_full_resource_pool_memory: 268435456
  30. workers_per_cpu_quota: 10
  31. schema_history_expire_time: 1d
  32. # The value of net_thread_count had better be same as cpu's core number.
  33. net_thread_count: 4
  34. major_freeze_duty_time: Disable
  35. minor_freeze_times: 10
  36. enable_separate_sys_clog: 0
  37. enable_merge_by_turn: FALSE
  38. datafile_disk_percentage: 20 # The percentage of the data_dir space to the total disk space. This value takes effect only when datafile_size is 0. The default value is 90.
  39. datafile_size: 50G
  40. syslog_level: WRAN # System log level. The default value is INFO.
  41. enable_syslog_wf: false # Print system logs whose levels are higher than WARNING to a separate log file. The default value is true.
  42. enable_syslog_recycle: true # Enable auto system log recycling or not. The default value is false.
  43. max_syslog_file_count: 10 # The maximum number of reserved log files before enabling auto recycling. The default value is 0.
  44. # observer cluster name, consistent with obproxy's cluster_name
  45. appname: obce-3zones
  46. root_password: 12346 # root user password, can be empty
  47. proxyro_password: 123456 # proxyro user pasword, consistent with obproxy's observer_sys_password, can be empty
  48. obce01:
  49. mysql_port: 2881 # External port for OceanBase Database. The default value is 2881. DO NOT change this value after the cluster is started.
  50. rpc_port: 2882 # Internal port for OceanBase Database. The default value is 2882. DO NOT change this value after the cluster is started.
  51. # The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.
  52. home_path: /root/obce-3zones
  53. # The directory for data storage. The default value is $home_path/store.
  54. data_dir: /data/obce-3zones
  55. # The directory for clog, ilog, and slog. The default value is the same as the data_dir value.
  56. redo_dir: /redo/obce-3zones
  57. zone: zone1
  58. obce02:
  59. mysql_port: 2881 # External port for OceanBase Database. The default value is 2881. DO NOT change this value after the cluster is started.
  60. rpc_port: 2882 # Internal port for OceanBase Database. The default value is 2882. DO NOT change this value after the cluster is started.
  61. # The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.
  62. home_path: /root/obce-3zones
  63. # The directory for data storage. The default value is $home_path/store.
  64. data_dir: /data/obce-3zones
  65. # The directory for clog, ilog, and slog. The default value is the same as the data_dir value.
  66. redo_dir: /redo/obce-3zones
  67. zone: zone2
  68. obce03:
  69. mysql_port: 2881 # External port for OceanBase Database. The default value is 2881. DO NOT change this value after the cluster is started.
  70. rpc_port: 2882 # Internal port for OceanBase Database. The default value is 2882. DO NOT change this value after the cluster is started.
  71. # The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.
  72. home_path: /root/obce-3zones
  73. # The directory for data storage. The default value is $home_path/store.
  74. data_dir: /data/obce-3zones
  75. # The directory for clog, ilog, and slog. The default value is the same as the data_dir value.
  76. redo_dir: /redo/obce-3zones
  77. zone: zone3
  78. obproxy:
  79. # Set dependent components for the component.
  80. # When the associated configurations are not done, OBD will automatically get the these configurations from the dependent components.
  81. depends:
  82. - oceanbase-ce
  83. servers:
  84. - 172.17.237.62
  85. global:
  86. listen_port: 2883 # External port. The default value is 2883.
  87. prometheus_listen_port: 2884 # The Prometheus port. The default value is 2884.
  88. home_path: /root/obproxy
  89. # oceanbase root server list
  90. # format: ip:mysql_port;ip:mysql_port. When a depends exists, OBD gets this value from the oceanbase-ce of the depends.
  91. rs_list: 172.17.237.61:2881;172.20.126.115:2881;172.28.240.128:2881
  92. enable_cluster_checkout: false
  93. # observer cluster name, consistent with oceanbase-ce's appname. When a depends exists, OBD gets this value from the oceanbase-ce of the depends.
  94. cluster_name: obce-3zones
  95. skip_proxy_sys_private_check: true
  96. obproxy_sys_password: 123456 # obproxy sys user password, can be empty. When a depends exists, OBD gets this value from the oceanbase-ce of the depends.
  97. observer_sys_password: 123465 # proxyro user pasword, consistent with oceanbase-ce's proxyro_password, can be empty. When a depends exists, OBD gets this value from the oceanbase-ce of the depends.

将用户名,IP地址等修改为自己所对应的值即可。

保存后重命名为集群名:obce-3zones.yaml

3.2 部署

部署使用命令:obd cluster deploy [集群名] -c 集群配置文件 。

obd cluster deploy obce-3zones -c obce-3zones.yaml

检查集群部署状态,为deployed。

obd cluster list

启动集群

obd cluster start obce-3zones

确定集群启动成功,为running: 

obd cluster list

3.3 部署可能会出现的问题

open ssh connection报错问题

在部署时,可能会出现在open ssh connection处报错:

这是前面初始化没有做好,没有打通ssh的问题,回到2.4 配置ssh免密登录再试一试。

Cluster NTP is out of sync 报错问题 

服务器初始化时的时间同步没有处理好:用clockdiff查相应节点,Oceanbase集群要求delta不能超过100ms。处理方法在本文2.3 时间同步处理。

最终部署成功:

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

闽ICP备14008679号