引言:
本地物理服务器集群搭建ntp时间同步环境,使用一台机器作为本地server端连接阿里云授时中心,其他节点配置本地server为首选。
本地集群server端配置
安装软件包
#yum install ntp -y ;
修改配置
# vim /etc/ntp.conf
# Hosts on local network are less restricted.
# 配置使用本ntp server的IP端
restrict 172.16.xx.0 mask 255.255.255.0 nomodify notrap
#使用阿里云的授时服务器
server time1.aliyun.com prefer
server time2.aliyun.com
server time3.aliyun.com
server time4.aliyun.com
server time5.aliyun.com
server time6.aliyun.com
server time7.aliyun.com
重启服务
# service ntpd restart
检查状态
# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*203.107.6.88 100.107.25.114 2 u 32 64 377 19.203 -1.571 0.264
经查询,203.107.6.88 是time4.aliyun.com,配置生效。
本地其他节点配置
安装软件包
# yum install ntp -y ;
修改配置
# vim /etc/ntp.conf
server 172.16.xx.17 prefer #优先使用本地ntp服务器
server time1.aliyun.com #使用阿里云的授时服务器
server time2.aliyun.com
server time3.aliyun.com
server time4.aliyun.com
server time5.aliyun.com
server time6.aliyun.com
server time7.aliyun.com
启动服务
systemctl enable ntpd;
service ntpd start;
ntpq -p;
启动ntp服务,同时设置服务开机自启
检查状态
# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*node17 203.107.6.88 3 u 3 64 17 0.104 -1.316 1.241
+203.107.6.88 100.107.25.114 2 u 5 64 17 19.636 -2.990 2.205
可以发现当前节点首先去本地NTP服务器同步时间,node17的ntp上级服务器为203.107.6.88。与17节点查询相同,服务正常。