A. Environment Preparation
xuegod63.cn Service Side
xuegod64.cn Client
two. Server-side configuration:
1. Installing the NTP service
[[email protected] ~]# Yum install-y NTP
2. turn on the NTPD service and set the boot up
[[Email protected] ~]# service NTPD start
Starting ntpd: [OK]
[Email protected] ~]# chkconfig ntpd on
3. To see if the port is started
[Email protected] ~]# netstat-anput| grep 123
UDP 0 0 172.16.30.39:123 0.0.0.0:* 2107/ntpd
udp 0 0 127.0.0.1:123 0.0.0.0:* 2107/ntpd
udp 0 0 0.0.0.0:123 0.0.0.0:* 2107/ntpd
udp 0 0fe80::5054:ff:fee4:1f53:123:::* 2107/ntpd
udp 0 0::1:123 :::* 2107/ntpd
UDP 0 0::: 123:::* 2107/ntpd
4. Sync Time:
[email protected] ~]# ntpdate0.centos.pool.ntp.org (because the NTPD service sync time error is turned on)
11:30:47 ntpdate[2116]: The NTP socketis in use, exiting
[[Email protected] ~]# service NTPD stop
Close ntpd: [OK]
[Email protected] ~]# ntpdate0.centos.pool.ntp.org
May 11:31:40 ntpdate[2128]: adjust Timeserver 202.112.29.82 offset-0.018094 sec
5. To Modify a configuration file:
[Email protected] ~]# vim/etc/ntp.conf
Restrict 127.0.0.1
Restrict-6:: 1
Restrict 192.168.1.0 mask 255.255.255.0 # allow access to 192.168.1.0 network segments
Server 127.127.1.0 # Local Clock address
Fudge 127.127.1.0 Stratum Local 127.127.1.0 is 10th floor
6. Restart ntpd Service
[Email protected] ~]#/etc/init.d/ntpd restart
Close ntpd: [Failed]
Starting ntpd: [OK]
7. Test:
Before testing, to detect whether the firewall, SELinux are off!!!
Service side:
[[Email protected] ~]# Date
. May 24 Tuesday 15:54:55 CST
[email protected] ~]# date-s "2016-05-2415:30" # Set the time
. May 24 Tuesday 15:30:00 CST
[email protected] ~]# Clock–w # Synchronize to hardware simultaneously
[[Email protected] ~]# Date
. May 24 Tuesday 15:30:14 CST
[Email protected] ~]# service ntpd restart
Close ntpd: [OK]
Starting ntpd: [OK]
[[Email protected] ~]# Date
. May 24 Tuesday 15:30:29 CST
Three Client testing:
[Email protected] ~]# ntpdate 172.16.30.39
May 15:30:37 ntpdate[15939]: Step timeserver 172.16.30.39 offset-1504.826538 sec
[[Email protected] ~]# Date
Tue 15:30:40 CST 2016
Common errors:
APR 15:30:17 ntpdate[11520]: noserver suitable for synchronization found
In fact, this is not a mistake. Instead, it takes approximately 3-5 minutes after each restart of the NTP server for the client to establish a normal communication connection with the server. This information is reported when the client connects to the server at this time. It usually takes a few minutes to wait.
This article is from the "Mo Hua Kai" blog, please be sure to keep this source http://ruofeng.blog.51cto.com/4313888/1782610
Deploy NTP servers for time synchronization