1. 选定其中一台服务器作为基准服务器,即提供时钟服务。
(1)首先确定ntp是否存在,若不存在则通过以下命令安装:
1. yum install ntp
(2)修改配置文件/etc/ntp.conf,在其中插入:
1. restrict 192.168.20.0 mask 255.255.255.0 nomodify notrap
其中:
用restrict控管权限
nomodify - 用户端不能更改ntp服务器的时间参数
noquery - 用户端不能使用ntpq,ntpc等命令来查询ntp服务器
notrap - 不提供trap远端登陆
(3)此时可以向192.168.20.0/24的机器提供时间服务了,开启ntp服务:
1. /etc/rc.d/init.d/ntp start // 启动ntp服务
2. chkconfig ntpd on // 让ntp服务开机启动
(4)检查ntp端口是否已经开启:
1. netstat -unlnp
如果正常,应该可以看到123端口已经开启。
2. 客户端同步(使用ntpd服务)
也可以使用ntpdate手动同步( ntpdate xxx.xxx.xxx.xxx),但我在这里推荐使用ntpd服务进行自动同步,更多请参考:如流,新一代智能工作平台
(1)修改/etc/ntp.conf,在里边插入:
1. server 192.168.20.91
(2)使ntpd服务开启启动
1. chkconfig ntpd on
(3)启动客户端ntpd服务
1. /etc/rc.d/init.d/ntpd start