您的位置:首页 > 运维架构 > Linux

Linux下两个主机NTP同步

2015-09-08 11:48 591 查看
主机IP
single192.168.188.12
single2192.168.188.13
以single2作为server,single作为client。

一、首先检查single2中是否安装了ntp

rpm -qa | grep ntp

[root@single2 ~]# rpm -qa | grep ntp

ntp-4.2.2p1-15.el5_7.1

chkfontpath-1.10.1-1.1

说明有了,如果没有,配置yum,安装上就ok。

二、配置vi /etc/ntp.conf

1.配置所有人都可以使用这个single2同步时间

restrict default kod nomodify notrap nopeer noquery

restrict -6 default kod nomodify notrap nopeer noquery

2.或者,配置只能某个网段使用single2同步,比如single:192.168.188.*

在restrict default nomodify notrap noquery(表示默认拒绝所有IP的时间同步)之后增加一行:

restrict 192.168.188.0 mask 255.255.255.0 nomodify notrap

然后启动ntp:

service ntpd start

chkconfig ntpd on

然后等待五分钟,休息一下,就可以在client测试了:

[root@single ~]# date -s '2015-1-1 00:00:00'

Thu Jan 1 00:00:00 CST 2015

[root@single ~]# ntpdate 192.168.188.13

8 Sep 11:44:27 ntpdate[2867]: step time server 192.168.188.13 offset 21642245.404456 sec

[root@single ~]# date

Tue Sep 8 11:44:30 CST 2015

[root@single ~]#

搞定!

注:1.在client不用起ntpd。

2.如果在client执行ntpdate serverIP,报错:no server suitable for synchronization found,那就再等几分钟,给server个准备的时间。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: