原创作品,允许转载,转载时请务必以超链接形式标明文章
原始出处 、作者信息和本声明。否则将追究法律责任。
http://navyaijm.blog.51cto.com/4647068/809455
# yum install ntp -y
2. 让本服务器时间与 3.cn.pool.ntp.org 时间同步;
[root@localhost ~]# ntpdate 3.cn.pool.ntp.org
3. 自动同步服务器时钟
[root@localhost ~]# crontab -e
* */4 * * * /usr/sbin/ntpdate 3.cn.pool.ntp.org
[root@localhost ~]# service crond restart
4.配置 ntp.conf
[root@localhost ~]# vi /etc/ntp.conf
restrict default nomodify notrap noquery
restrict 10.20.220.0 mask 255.255.254.0 nomodify notrap
restrict 10.20.216.0 mask 255.255.254.0 nomodify notrap
restrict 10.20.221.0 mask 255.255.254.0 nomodify notrap
restrict 127.0.0.1
restrict -6 ::1
server 3.cn.pool.ntp.org
server 10.20.220.251
server time.lib.tsinghua.edu.cn
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 8
driftfile /var/lib/ntp/drift
keys /etc/ntp/keys
logfile /var/log/ntp.log
broadcastdelay 0.008
5.启动或停止时间服务
# service ntpd start
# service ntpd stop
# service ntpd restart
6.验证ntp服务已经运行
# pgrep ntpd
#123端口是否开启
7.初始同步
# ntpdate -u 3.cn.pool.ntp.org
8.确认同步成功
[root@localhost ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*61.153.197.226 66.220.9.122 2 u 188 256 377 25.124 12.510 2.999
10.20.220.251 .INIT. 16 u - 1024 0 0.000 0.000 0.000
web.lib.tsinghu .INIT. 16 u - 1024 0 0.000 0.000 0.000
+114.80.81.1 209.81.9.7 2 u 168 256 377 27.492 -31.989 1.283
LOCAL(0) .LOCL. 8 l 23 64 377 0.000 0.000 0.001
9.linux客户端设置NTP
2. 让本服务器时间与 3.cn.pool.ntp.org 时间同步;
[root@localhost ~]# ntpdate 3.cn.pool.ntp.org
3. 自动同步服务器时钟
[root@localhost ~]# crontab -e
* */4 * * * /usr/sbin/ntpdate 3.cn.pool.ntp.org
[root@localhost ~]# service crond restart
4.配置 ntp.conf
[root@localhost ~]# vi /etc/ntp.conf
restrict default nomodify notrap noquery
restrict 10.20.220.0 mask 255.255.254.0 nomodify notrap
restrict 10.20.216.0 mask 255.255.254.0 nomodify notrap
restrict 10.20.221.0 mask 255.255.254.0 nomodify notrap
restrict 127.0.0.1
restrict -6 ::1
server 3.cn.pool.ntp.org
server 10.20.220.251
server time.lib.tsinghua.edu.cn
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 8
driftfile /var/lib/ntp/drift
keys /etc/ntp/keys
logfile /var/log/ntp.log
broadcastdelay 0.008
5.启动或停止时间服务
# service ntpd start
# service ntpd stop
# service ntpd restart
6.验证ntp服务已经运行
# pgrep ntpd
#123端口是否开启
7.初始同步
# ntpdate -u 3.cn.pool.ntp.org
8.确认同步成功
[root@localhost ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*61.153.197.226 66.220.9.122 2 u 188 256 377 25.124 12.510 2.999
10.20.220.251 .INIT. 16 u - 1024 0 0.000 0.000 0.000
web.lib.tsinghu .INIT. 16 u - 1024 0 0.000 0.000 0.000
+114.80.81.1 209.81.9.7 2 u 168 256 377 27.492 -31.989 1.283
LOCAL(0) .LOCL. 8 l 23 64 377 0.000 0.000 0.001
9.linux客户端设置NTP
server
127.127.
1.0
fudge 127.127. 1.0 stratum 8
fudge 127.127. 1.0 stratum 8
#
watch ntpq -p
transmit(192.168.30.22)
.....
28 Jul 17:42:24 ntpdate[14148]: no server suitable for synchronization found
28 Jul 17:42:24 ntpdate[14148]: no server suitable for synchronization found
#
ntpq -c version
#
service iptables stop