关于Centos集群时间同步

Published on with 0 views and 0 comments

  

安装 chrony

  yum install chrony -y

修改配置文件

  VIM /etc/chrony.config

master

 1
 2// 这里 写Master节点的地址 
 3server 111.111.111.111 iburst
 4
 5# Record the rate at which the system clock gains/losses time.
 6driftfile /var/lib/chrony/drift
 7
 8# Allow the system clock to be stepped in the first three updates
 9# if its offset is larger than 1 second.
10makestep 1.0 3
11rtcsync
12
13# Enable hardware timestamping on all interfaces that support it.
14#hwtimestamp *
15
16# Increase the minimum number of selectable sources required to adjust
17# the system clock.
18#minsources 2
19
20# Allow NTP client access from local network.
21#allow 192.168.0.0/16
22// 这里allow所有网段或者改成你自己的网段
23allow
24# Serve time even if not synchronized to a time source.
25// 这里打开即使不与时间源同步,也提供时间
26local stratum 10
27
28# Specify file containing keys for NTP authentication.
29#keyfile /etc/chrony.keys
30
31# Specify directory for log files.
32logdir /var/log/chrony
33
34# Select which information is logged.
35#log measurements statistics tracking
1// 重启服务
2systemctl restart chronyd

  然后把文件分发到各个 子机 上

1scp /etc/chrony.conf root@xxx:/etc/chrony.conf

  子机重启服务

1systemctl restart chronyd

  查看 是否 同步成功

1chronyc sources
1210 Number of sources = 1
2MS Name/IP address         Stratum Poll Reach LastRx Last sample               
3===============================================================================
4^* master-1                     11   9   377   502    +18us[  +31us] +/-   15ms

  ^* = 成功

  ^? = 不成功

  不成功的原因可能是由于 NTP 没有开启导致

1timedatectl set-ntp true

  然后在重启 master node 的 chronyd


标题:关于Centos集群时间同步
作者:fe
地址:https://blog.eiyouhe.com/articles/2020/03/19/1584630034279.html