NTP主服务器IP地址:192.168.33.13
NTP从服务器IP地址:192.168.33.12
(一)NTP服务器搭建 192.168.33.13服务器
1、配置ntp.conf
vi /etc/ntp.conf
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict -6 ::1
restrict 192.168.33.0 mask 255.255.255.0 nomodify notrap
server 192.168.33.13
server 0.centos.pool.ntp.org
server 1.centos.pool.ntp.org
server 2.centos.pool.ntp.org
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
2、vi /etc/sysconfig/ntpd
# Drop root to id 'ntp:ntp' by default.
OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid -x"
# Set to 'yes' to sync hw clock after successful ntpdate
SYNC_HWCLOCK=yes
# Additional options for ntpdate
NTPDATE_OPTIONS=""
注意: 如果没有加-x,后面在做CVU检查的时候会报 RVF-5436 : 在一个或多个节点上运行的 NTP 守护程序缺少快速定向选项 "-x"
3、编辑 /etc/ntp/ntpservers
vi /etc/ntp/ntpservers
0.centos.pool.ntp.org
1.centos.pool.ntp.org
2.centos.pool.ntp.org
4、编辑 vi /etc/ntp/step-tickers文件,加入
vi /etc/ntp/step-tickers
pool.ntp.org
5、上诉修改完成后,以root用户身份重启ntpd服务:
service ntpd restart
过5~10分钟之后启动客户端,就可以看到服务器端的效果了,可以在windows端进行测试。
(二)Linux NTP客户端搭建 192.168.33.12客户端
方法一
配置LINUX客户端
在linux客户端上执行ntpdate ntp_server_ip 就可以根据时间服务器统一局域网的时间了,将上面的命令放到cron里每天早上3点定期执行,
crontab –e
然后输入
0 3 * * * /usr/sbin/ntpdate 192.168.33.13
方法二
1、/etc/sysconfig/ntpd的配置
# Drop root to id 'ntp:ntp' by default.
OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid -x"
SYNC_HWCLOCK=yes
# Additional options for ntpdate
TE_OPTIONS=""
2、配置 /etc/ntp/step-tickers
# vi /etc/ntp/step-tickers
192.168.33.13
3、/etc/ntp.conf的配置
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict -6 ::1
restrict 192.168.33.0 mask 255.255.255.0 nomodify notrap
server 0.centos.pool.ntp.org
server 1.centos.pool.ntp.org
server 2.centos.pool.ntp.org
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
4、 vi /etc/ntp/ntpservers
0.centos.pool.ntp.org
1.centos.pool.ntp.org
2.centos.pool.ntp.org
remote refid st t when poll reach delay offset jitter
==============================================================================
rac2 114.80.81.13 3 u 9 64 1 0.172 0.076 0.001
rac2: stratum 3, offset 0.024355, synch distance 0.194971
114.80.81.13: stratum 2, offset 0.002255, synch distance 0.081637
clock.fmt.he.net: stratum 1, offset 0.000002, synch distance 0.000435, refid 'CDMA'