[原]NTP时钟同步服务设置

服务器列表
192.168.0.2 ntp服务端
192.168.0.3 ntp客户端
192.168.0.4 ntp客户端
192.168.0.5 ntp客户端

注:以下操作均以root操作

一、NTP服务端

1.设置系统时间并写入硬件时钟,确保重启后时间不会改变。

设置系统时间
date -s "2017-07-21 10:20:00"

时间写入硬件
hwclock -w

2.设置NTP服务端作为时钟同步源

vi /etc/ntp.conf

#server 0.rhel.pool.ntp.org iburst
#server 1.rhel.pool.ntp.org iburst
#server 2.rhel.pool.ntp.org iburst
#server 3.rhel.pool.ntp.org iburst
server 127.127.1.0
fudge 127.127.1.0 stratum 10

3.设置授权客户端

vi /etc/ntp.conf
restrict 192.168.0.3 mask 255.255.255.0 nomodify notrap
restrict 192.168.0.4 mask 255.255.255.0 nomodify notrap
restrict 192.168.0.4 mask 255.255.255.0 nomodify notrap

4.启动NTP服务并设置开机自动启动

/etc/init.d/ntpd restart
chkconfig --level 0123456 ntpd on

二、NTP客户端

1.配置NTP服务端

vi /etc/ntp.conf
server 192.168.0.2

2.手动同步时钟

先停止NTP服务
/etc/init.d/ntpd stop
手动同步时钟
ntpdate 192.168.0.2

3.启动NTP服务并设置开启自动启动

/etc/init.d/ntpd restart
chkconfig --level 0123456 ntpd on

4.查看NTP同步状态

watch ntpq -p
心有多大,林子就有多大
原文地址:https://www.cnblogs.com/liuyungao/p/7216671.html