NTP时间服务器配置
原配置文件中第21-24行可以注释掉:修改为国内公网上的时间服务器(26、27行);当外部时间不可用时,采用本地时间(28、29行)这个问题往往是由于npt服务的123端口被其他服务占用引起,这个占用服务一般是chronyd。这个问题是由于防火墙挡住了ntp端口,使用上买你的firewall-cmd命令解决。4.在防火墙开放对应端口,服务器和客户端均需开放123/udp端口。在/etc/ntp.c
1.在服务器上安装ntp服务
[root@kevin ~]# yum install -y ntp
2.主配置文件在/etc/ntp.conf,修改该文件,新增一个日志路径:
[root@kevin ~]# vi /etc/ntp.conf
logfile /var/log/ntpd.log
授权特定网段的主机可以从此时间服务器上查询和同步时间:
restrict 192.168.100.0 mask 255.255.255.0 nomodify notrap
原配置文件中第21-24行可以注释掉: 修改为国内公网上的时间服务器(26、27 行);当外部时间不可用时,采用本地时间(28、29行)
#server 0.centos.pool.ntp.org iburst #server 1.centos.pool.ntp.org iburst #server 2.centos.pool.ntp.org iburst #server 3.centos.pool.ntp.org iburst server 210.72.145.44 server ntp1.aliyun.com server 127.0.0.1 fudge 127.0.0.1 stratum 10 |
3.修改完成后,重启服务: 并手动同步服务器时间与公网服务器时间一致:
[root@kevin ~]# systemctl restart ntpd
[root@kevin ~]# ntpdate -u ntp1.aliyun.com
18 Dec 21:54:59 ntpdate[1471]: adjust time server 120.25.115.20 offset -0.001798 sec
4.在防火墙开放对应端口,服务器和客户端均需开放123/udp端口
firewall-cmd --zone=public --add-port=123/udp --permanent firewall-cmd --reload |
第六步 启动ntp 服务
systemctl enable ntpd 开机启动
systemctl start ntpd
sytemctl status ntpd
第七步 验证服务
ntpq -p
date -R
第八步
同步远程时间服务
ntpdate -q 0.ro.pool.ntp.org 1.ro.pool.ntp.org
第九步 在客户端机器同步时间
ntpdate -d -b 192.168.85.20
可能遇到的问题
1 centos stratum 0, precision 0, leap 00, trust 000 no server suitable for synchronization found
这个问题是由于防火墙挡住了ntp 端口,使用上买你的firewall-cmd 命令解决
2 stratum too high 的问题
在/etc/ntp.conf 中 修改 stratum 的值
3 NTP开机无法启动的解决方法
这个问题往往是由于npt 服务的123 端口被其他服务占用引起,这个占用服务一般是chronyd
禁用这个服务即可
systemctl disable chronyd
更多推荐
所有评论(0)