环境 2台CentOS6.6作为时间服务器主备 后端有linux和windows服务器
使用2台负载服务器作为时间服务器 后端机器指向此服务器
ntpserver
10.0.0.7
10.0.0.8
添加acl 接受公司内/外网段服务器访问
上一级时间服务器信息
[root@Z xxxxxxY-HAPROXY-02 ~]# vim /etc/ntp.conf
#default configure
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict -6 ::1
driftfile /var/lib/ntp/drift
keys /etc/ntp/keys
disable monitor
#ACL
restrict 10.109.37.0 mask 255.255.255.0 nomodify
restrict 10.109.38.0 mask 255.255.255.0 nomodify
restrict 10.109.39.0 mask 255.255.255.0 nomodify
restrict 124.203.235.0 mask 255.255.255.224 nomodify
#allow higher NTP servers to access OGsrv
restrict 0.asia.pool.ntp.org
restrict 1.asia.pool.ntp.org
restrict 2.asia.pool.ntp.org
restrict 3.asia.pool.ntp.org
restrict 3.cn.pool.ntp.org
# NTP server
server 0.asia.pool.ntp.org
server 1.asia.pool.ntp.org
server 2.asia.pool.ntp.org
server 3.asia.pool.ntp.org
server 3.cn.pool.ntp.org
~
"/etc/ntp.conf" 29L, 761C 29,0-1 All
启动服务器 service ntpd start
查看状态 netstat -anpu | grep ntp
开启防火墙接受后端网段访问
iptables -I INPUT -s 10.9.99.0/32 -p udp -m udp --dport 123 -j ACCEPT
后端服务器查看网络是否通
udp协议使用nc查看
nc -uvz 10.0.0.7 123
提示如下即端口连接成功
Connection to 10.9.38.254 123 port [udp/ntp] succeeded!
其余服务器执行更新
ntpdate -u 10.0.0.7
执行此命令会立即更新时间 有可能报错服务端不可用 原因是服务端刚刚开启服务 正在和上一级通信 等待五分钟之后更新即可
或者将时间服务器写入配置文件
vim /etc/ntp.conf
#ntp server IP
restrict 10.10.0.7
restrict 10.10.0.8
写入配置文件后重启服务 service ntpd restart
测试中 centos7可以立即更新正确时间 centos6重启服务后不会立即同步 大约等待了十分钟
均设置开机启动 chkconfig ntpd on
若后端为windows服务器
使用nmap测试端口是否通 桌面右下角设置
windows更改同步服务器 第一次同步可能会提示超时时间已过
再次点击立即更新即可
补充 : 时区修改 https://blog.csdn.net/zlt995768025/article/details/79765738
阿里云NTP服务器
ntp1.aliyun.com
ntp2.aliyun.com
ntp3.aliyun.com
ntp4.aliyun.com
ntp5.aliyun.com
ntp6.aliyun.com
ntp7.aliyun.com
腾讯云NTP服务器
time1.cloud.tencent.com
time2.cloud.tencent.com
time3.cloud.tencent.com
time4.cloud.tencent.com
time5.cloud.tencent.com
参考: 细说linux
参考:鸟哥blog