1.安装ntp:
yum install ntp
2.修改配置文件:
vi /etc/ntp.conf
把"restrict default kod nomodify notrap nopeer noquery"注释掉(表示默认拒绝所有IP的时间同步)
把"restrict -6 default kod nomodify notrap nopeer noquery"注释掉
添加"restrict default nomodify"(允许任何IP的客户机都可以进行时间同步)
把下面几行注释掉:
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 127.127.1.0
fudge 127.127.1.0 stratum 10
3.允许BIOS与系统时间同步:
vi /etc/sysconfig/ntpd
添加:SYNC_HWCLOCK="yes"
4.启动ntp服务,并添加开机启动:
service ntpd start
chkconfig ntpd on
chkconfig --list ntpd
chkconfig --level 35 ntpd on
5.防火墙设置
vi /etc/sysconfig/iptables
-A INPUT -p udp -m udp --sport 123 -j ACCEPT
service iptables restart
6.然后通过:ntpdate 192.168.3.237(这个就是上面安装ntp服务器对应的机器IP)可以进行时间同步
可能会报"no server suitable for synchronization found",
重启下ntp服务:service ntpd restart
7.注意,如果修改了ntp服务器的时间,必须要重启ntp服务,否则在其他服务器进行时间同步的时候
还会出现第六点的问题。
8.完毕