CentOS7叢集時間同步
阿新 • • 發佈:2021-01-05
參考資料
Linux - CentOS7上的時間同步 https://www.cnblogs.com/zhubiao/p/9768209.html
配置Linux例項Chrony服務(CentOS 7) https://help.aliyun.com/document_detail/187016.html?spm=a2c4g.11186623.2.23.54b829c59fG0tc
正文
執行以下命令修改時區
[[email protected] ~]# ln -sf /usr/share/zoneinfo/Asia/Hong-Kong /etc/localtime
執行以下命令更新硬體時鐘(RTC)
[[email protected]
執行以下命令檢視時區
[[email protected] ~]# timedatectl status
開啟chrony配置檔案
[[email protected] ~]# vim /etc/chrony.conf
# Use Alibaba NTP server # Public NTP # Alicloud NTP server ntp.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst server ntp.aliyun.com minpoll 4 maxpoll 10 iburst server ntp1.aliyun.com minpoll 4 maxpoll 10 iburst server ntp1.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst server ntp10.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst server ntp11.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst server ntp12.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst server ntp2.aliyun.com minpoll 4 maxpoll 10 iburst server ntp2.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst server ntp3.aliyun.com minpoll 4 maxpoll 10 iburst server ntp3.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst server ntp4.aliyun.com minpoll 4 maxpoll 10 iburst server ntp4.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst server ntp5.aliyun.com minpoll 4 maxpoll 10 iburst server ntp5.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst server ntp6.aliyun.com minpoll 4 maxpoll 10 iburst server ntp6.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst server ntp7.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst server ntp8.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst server ntp9.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst # Ignore stratum in source selection. stratumweight 0.05 # Record the rate at which the system clock gains/losses time. driftfile /var/lib/chrony/drift # Enable kernel RTC synchronization. rtcsync # In first three updates step the system clock instead of slew # if the adjustment is larger than 10 seconds. makestep 10 3 # Allow NTP client access from local network. #allow 192.168/16 # Listen for commands only on localhost. bindcmdaddress 127.0.0.1 bindcmdaddress ::1 # Disable logging of client accesses. noclientlog # Send a message to syslog if a clock adjustment is larger than 0.5 seconds. logchange 0.5 logdir /var/log/chrony #log measurements statistics tracking
執行以下命令啟動chronyd服務並設定開機自啟動。
[[email protected] ~]# systemctl start chronyd.service
[[email protected] ~]# systemctl enable chronyd.service
執行以下命令檢視本機時間同步狀態,用於驗證服務是否已啟動。
[[email protected] ~]# chronyc tracking
執行以下命令檢視時間同步伺服器列表。
[[email protected] ~]# chronyc -n sources -v
使用Chrony手動同步時鐘
[[email protected] ~]# chronyc
在Chrony工具內,執行makestep命令同步時鐘。