Sunday, April 17, 2016

Linux: Build NTP server in Centos 7

Centos7 SELinux closed, first confirm the firewall
[root@applog cat /etc/redhat-release ~]#
CentOS Linux release 7.0.1406 (Core)

The first step to install NTP ntpdate
[root@applog Yum install NTP ntpdate -y ~]#


The second step search time synchronization server
Http://www.pool.ntp.org/zone/asia


The third step to edit /etc/ntp.conf
Server time.windows.com
Server s2m.time.edu.cn
Server 0.asia.pool.ntp.org
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 when the external time is not available, use the local time.
IP restrict 172.100.1.0 mask 255.255.0.0 nomodify addresses allow update

Fourth steps to start the NTP service
Systemctl start ntpd
Systemctl enable ntpd.service set the boot service

The fifth step authentication 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 33643295.525 -9.062 7.868
Ns.pku.edu.cn.STEP. 16 u 6400 - 0 0
-nipper.paina.jp 103.1.106.69 2 u 36643189.334 48.582 0.068
-203.158.247.150 202.28.214.2 2 u 38643258.045 -83.101 0.123
+168.63.242.24 137.189.4.10 2 u 4564366.155 -6.473 0.343
*linode.dev.fawo 218.186.3.36 2 u 4464371.535 10.114 0.157
LOCAL (0).LOCL. 5 L 1126420 0 0
[root@applog date -R ~]#
Mon, 12 Oct 2015 10:56:06 +0800

The sixth step client remote time synchronization test
[root@nginx01 date ~]#
On Monday October 12, 2015 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

The seventh step client setting plan task, every night at 1 p.m. time synchronization
Crontab -e
1 * * * root /usr/sbin/ntpdate 172.100.1.119; /sbin/hwclock -w
To solve the error
[root@nginx01 ntpdate 172.100.1.119 ~]#
12 Oct 10:38:26 ntpdate[19199] server suitable for synchronization found: no
This is the wrong time server, no server time synchronization layer.

No comments:

Post a Comment