Linux时间同步
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
联网情况:ntpdate us.pool.ntp.org
修改时间
date -s 11:21:00
查看NTP状态
service ntpd status
yum install -y ntpd
chkconfig ntpd on
#查看时区
date -R
#同步网络时间
ntpdate 1.centos.pool.ntp.org
配置ntp服务端:
vi /etc/ntp.conf
restrict 172.16.0.0 mask 255.255.255.0 nomodify notrap
#使用本地时钟
server 127.127.1.0
fudge 127.127.1.0 stratum 10
保存退出
#开启防火墙udp 123端口
iptables -I INPUT -p udp --dport 123 -j ACCEPT
service iptables save
#在启动ntpd服务之前,先使用ntpdate手动同步下时间,免得本机与外部时间服务器时间差距太大,让ntpd不能正常同步。
ntpdate 0.centos.pool.ntp.org
#启动ntpd服务
service ntpd start
#其他机器机器发送同步请求
ntpdate 172.16.0.11
开机启动
/etc/rc.d/rc.local