Time synchronization is achieved through the NTP service.
1: First build local Yum source URL (http://www.cnblogs.com/zj21/p/6223462.html)
2: First install NTP service
[email protected] ~]# Yum install ntp-y
3: Modify the NTP configuration file
# For more information on this file, see the "the Man pages"
# ntp.conf (5), NTP_ACC (5), Ntp_auth (5), Ntp_clock (5), Ntp_misc (5), Ntp_mon (5).
Driftfile/var/lib/ntp/drift
# Permit time synchronization with We time source, but does not
# permit the source to a query or modify the service on this system.
Restrict default nomodify notrap nopeer noquery
# Permit All access over the loopback interface. This could
# is tightened as well, but to does so would effect some of
# the administrative functions.
Restrict 127.0.0.1
Restrict:: 1
# Hosts on local network is less restricted.
#restrict 192.168.1.0 Mask 255.255.255.0 nomodify notrap
# Use public servers from the Pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
Server 192.168.100.140 Iburst #目标网络地址
#server 1.centos.pool.ntp.org Iburst #注释掉默认的ntp服务器
#server 2.centos.pool.ntp.org Iburst
#server 3.centos.pool.ntp.org Iburst
#broadcast 192.168.1.255 AutoKey # Broadcast Server
#broadcastclient # Broadcast Client
#broadcast 224.0.1.1 AutoKey # Multicast Server
#multicastclient 224.0.1.1 # Multicast Client
#manycastserver 239.255.254.254 # Manycast Server
#manycastclient 239.255.254.254 AutoKey # manycast Client
# Enable Public Key cryptography.
#crypto
Includefile/etc/ntp/crypto/pw
# key file containing the keys and Key identifiers used when operating
# with symmetric key cryptography.
Keys/etc/ntp/keys
# Specify the key identifiers which is trusted.
#trustedkey 4 8 42
# Specify the key identifier to use with the NTPDC utility.
#requestkey 8
# Specify the key identifier to use with the NTPQ utility.
#controlkey 8
# Enable writing of Statistics records.
#statistics clockstats cryptostats loopstats peerstats
# Disable the monitoring facility to prevent amplification attacks using NTPDC
# monlist command When default restrict does not include the Noquery flag. See
Save exit.
4: Start the service and set the turn on self-starter
[Email protected] ~]# systemctl start Ntpd.service #启动服务
[Email protected] ~]# Systemctl enable Ntpd.service #设置为开机启动
[Email protected] ~]# systemctl status Ntpd.service #查看运行状态
Ntpd.service-network Time Service
Loaded:loaded (/usr/lib/systemd/system/ntpd.service; enabled; vendor preset:disabled)
Active:active (running) since two 2016-11-08 02:59:39 CST; 5min ago #红色部分为当前运行状态为running
Main pid:3185 (NTPD)
CGroup:/system.slice/ntpd.service
└─3185/usr/sbin/ntpd-u ntp:ntp-g
November 02:59:39 jw37 ntpd[3185]: Listen and drop on 0 v4wildcard 0.0.0.0 UDP 123
November 02:59:39 jw37 ntpd[3185]: Listen and drop on 1 V6wildcard:: UDP 123
November 02:59:39 jw37 ntpd[3185]: Listen normally on 2 lo 127.0.0.1 UDP 123
November 02:59:39 jw37 ntpd[3185]: Listen normally on 3 eno16777736 192.168.100.137 UDP 123
November 02:59:39 jw37 ntpd[3185]: Listen normally on 4 lo:: 1 UDP 123
November 02:59:39 jw37 ntpd[3185]: Listen normally on 5 eno16777736 FE80::20C:29FF:FE87:3EB2 UDP 123
November 02:59:39 jw37 ntpd[3185]: Listening on routing sockets on FD #22 for interface updates
November 02:59:39 jw37 ntpd[3185]: 0.0.0.0 c016 restart
November 02:59:39 jw37 ntpd[3185]: 0.0.0.0 c012, freq_set kernel 0.000 PPM
November 02:59:39 jw37 ntpd[3185]: 0.0.0.0 c011-Freq_not_set
Installation and configuration of time synchronization NTP service