本文介绍在局域网环境下配置 Chrony Server 和 Chrony Client 的详细步骤。
适用版本
OceanBase 所有版本
操作步骤
在每一台 Chrony Server 和 Chrony Client 服务器上,停止并禁用 NTP 时钟同步服务。
systemctl stop ntpd systemctl disable ntpd mv /etc/ntp.conf /etc/ntp.conf.bak在每一台 Chrony Server 和 Chrony Client 服务器上,安装 Chrony 时钟服务软件包(如果服务器上已经安装了该软件包则可以跳过这一步)。
yum install chrony -y rpm -qa | grep chrony在局域网环境内挑选一台稳定的服务器(比如安装 OAT/OCP 的服务器)作为 Chrony Server 时钟源服务器,配置
/etc/chrony.conf文件如下。说明
在修改
/etc/chrony.conf配置文件之前,建议将原/etc/chrony.conf文件做一个备份,此命令如下:cp /etc/chrony.conf /etc/chrony.conf.bak假设这边的 Chrony Server IP 地址为:172.xxx.xxxx.8,局域网网段为:172.xxx.xxxx.0/16。实际配置时需要根据具体环境的 IP 地址做相应的调整。
server 172.xxx.xxxx.8 minpoll 4 maxpoll 6 iburst maxslewrate 500 # Record the rate at which the system clock gains/losses time. driftfile /var/lib/chrony/drift # Allow the system clock to be stepped in the first three updates # if its offset is larger than 1 second. makestep 1.0 3 # Enable kernel synchronization of the real-time clock (RTC). rtcsync # Enable hardware timestamping on all interfaces that support it. #hwtimestamp * # Increase the minimum number of selectable sources required to adjust # the system clock. #minsources 2 # Allow NTP client access from local network. allow 172.xxx.xxxx.0/16 # Serve time even if not synchronized to a time source. local stratum 10 # Specify file containing keys for NTP authentication. #keyfile /etc/chrony.keys # Specify directory for log files. logdir /var/log/chrony # Select which information is logged. #log measurements statistics tracking参数说明:
minpoll:chrony 客户端向时钟源发起时间同步请求的最小时间间隔,单位为秒,默认值:4。
maxpoll:chrony 客户端向时钟源发起时间同步请求的最大时间间隔,单位为秒,默认值:6。
maxslewrate:用于控制 chrony 客户端时钟的最大调整速率,单位为 PPM (百万分之一),默认值:500。
启动 Chronyd 服务。
systemctl start chronyd.service systemctl enable chronyd.service systemctl status chronyd.service验证时钟服务。
chronyc -n sources返回结果如下:
MS Name/IP address strarum Poll Reach LastRX Last sample ================================================================================== ^* 172.xxx.xxxx.8 2 4 377 16 -322us [ -340us] -/- 26ms注意
此处输出需要包含
^* xxx.xxx.xxx.xxx才表示时间同步服务配置成功。在每一台 Chrony Client 服务器上,配置
/etc/chrony.conf文件如下。说明
在修改
/etc/chrony.conf配置文件之前,建议将原/etc/chrony.conf文件做一个备份,此命令如下:cp /etc/chrony.conf /etc/chrony.conf.bakserver 172.xxx.xxxx.8 minpoll 4 maxpoll 6 iburst maxslewrate 500 # Record the rate at which the system clock gains/losses time. driftfile /var/lib/chrony/drift # Allow the system clock to be stepped in the first three updates # if its offset is larger than 1 second. makestep 1.0 3 # Enable kernel synchronization of the real-time clock (RTC). rtcsync # Enable hardware timestamping on all interfaces that support it. #hwtimestamp * # Increase the minimum number of selectable sources required to adjust # the system clock. #minsources 2 # Allow NTP client access from local network. #allow 192.168.0.0/16 # Serve time even if not synchronized to a time source. #local stratum 10 # Specify file containing keys for NTP authentication. #keyfile /etc/chrony.keys # Specify directory for log files. logdir /var/log/chrony # Select which information is logged. #log measurements statistics tracking启动 Chronyd 服务。
systemctl start chronyd.service systemctl enable chronyd.service systemctl status chronyd.service验证时钟服务。
chronyc -n sources返回结果如下:
MS Name/IP address Stratum Poll Reach LastRx Last sample =============================================================================== ^* 172.xxx.xxxx.8 2 4 377 3 +2510ns[ -27us] +/- 24ms注意
此处输出需要包含
^* xxx.xxx.xxx.xxx才表示时间同步服务配置成功。
注意事项
因为 OBServer 数据库对系统时间服务有强依赖,且 OBServer 默认系统时钟戳都是单调递增的,因此,强烈建议在安装部署 MetaDB/OCP/OceanBase 集群前就将系统时钟同步服务配置到位。
如果 OceanBase 集群已经正在运行了,这个时候需要去调整系统时钟同步服务或者调整系统时间,请在 OceanBase 技术支持人员的指导下进行系统时间调整的操作。默认情况下,OceanBase 是不支持将系统时间调快或者调慢。