[root@localhost ~]# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
[root@localhost ~]# yum -y install ntp [root@localhost ~]# ntpdate 192.168.26.11 6 Sep 16:26:07 ntpdate[65736]: adjust time server 192.168.26.11 offset -0.001832 sec #可加入Crontab定时任务,每隔十分钟同步一次 */10 * * * * ntpdate 192.168.26.11
[root@localhost ~]# yum -y install ntp [root@localhost ~]# cat /etc/ntp.conf |awk '{if($0 !~ /^$/ && $0 !~ /^#/) {print $0}}' restrict default ignore #默认不允许修改或者查询ntp,并且不接收特殊封包 restrict 127.0.0.1 #给于本机所有权限 restrict 192.168.1.0 mask 255.255.255.0 notrap nomodify #给于局域网机的机器有同步时间的权限 server 192.168.26.11 prefer #设置时间服务器,加prefer表示优先 server 127.127.1.0 # local clock fudge 127.127.1.0 stratum 10 driftfile /var/lib/ntp/drift keys /etc/ntp/keys [root@localhost ~]# service ntpd restart 关闭 ntpd:[失败] 正在启动 ntpd:[确定] #查看时程 [root@localhost ~]# netstat -upnl |grep ntpd udp 0 0 192.168.211.238:123 0.0.0.0:* 65760/ntpd udp 0 0 127.0.0.1:123 0.0.0.0:* 65760/ntpd udp 0 0 0.0.0.0:123 0.0.0.0:* 65760/ntpd udp 0 0 ::1:123 :::* 65760/ntpd udp 0 0 fe80::eabd:d1ff:fefc:f16:123 :::* 65760/ntpd udp 0 0 fe80::eabd:d1ff:fefc:f16:123 :::* 65760/ntpd udp 0 0 :::123 :::* 65760/ntpd #查看同步结果 [root@localhost ~]# ntpstat synchronised to NTP server (192.168.26.11) at stratum 5 time correct to within 8202 ms polling server every 64 s #设置开机启动 [root@localhost ~]# chkconfig ntpd on
/var/log/messages
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有