centos7下首先确认防火墙、selinux关闭状态node
[root@applog ~]# cat /etc/redhat-release
CentOS Linux release 7.0.1406 (Core)linux
第一步 安装ntp ntpdatenginx
[root@applog ~]# yum install ntp ntpdate -ywindows
第二步 查找时间同步服务器centos
http://www.pool.ntp.org/zone/asia
服务器
第三步 编辑 /etc/ntp.confapp
server time.windows.comide
server s2m.time.edu.cn测试
server 0.asia.pool.ntp.orgui
server 1.asia.pool.ntp.org
server 2.asia.pool.ntp.org
server 3.asia.pool.ntp.org
server 127.127.1.0 iburst local clock 当外部时间不可用时,使用本地时间。
restrict 172.100.1.0 mask 255.255.0.0 nomodify 容许更新的IP地址段
第四步 启动ntp服务
systemctl start ntpd
systemctl enable ntpd.service 设置开机启动服务
第五步 验证服务
[root@applog ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
+23.102.23.44 188.114.116.1 3 u 33 64 3 295.525 -9.062 7.868
ns.pku.edu.cn .STEP. 16 u - 64 0 0.000 0.000 0.000
-nipper.paina.jp 103.1.106.69 2 u 36 64 3 189.334 48.582 0.068
-203.158.247.150 202.28.214.2 2 u 38 64 3 258.045 -83.101 0.123
+168.63.242.24 137.189.4.10 2 u 45 64 3 66.155 -6.473 0.343
*linode.dev.fawo 218.186.3.36 2 u 44 64 3 71.535 10.114 0.157
LOCAL(0) .LOCL. 5 l 112 64 2 0.000 0.000 0.000
[root@applog ~]# date -R
Mon, 12 Oct 2015 10:56:06 +0800
第六步 远程客户端时间同步测试
[root@nginx01 ~]# date
2015年 10月 12日 星期一 10:30:01 CST
[root@nginx01 ~]# ntpdate 172.100.1.119
12 Oct 11:12:11 ntpdate[19962]: step time server 172.100.1.119 offset 1667.466210 sec
第七步 客户端设置计划任务,天天晚上1点同步时间
crontab -e
00 01 * * * root /usr/sbin/ntpdate 172.100.1.119; /sbin/hwclock -w
报错解决
[root@nginx01 ~]# ntpdate 172.100.1.119
12 Oct 10:38:26 ntpdate[19199]: no server suitable for synchronization found
这个错误是时间服务器,尚未同步上层时间服务器。