[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.11spa
[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.net
/var/log/messagesrest