1.ntp时间服务Client(客户端)及服务器端配置---(ntp服务端客户端都使用ntpd服务,对/etc/ntpd.conf配置)
# For more information about this file, see 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 our time source, but do not
# permit the source to query or modify the service on this system.
restrict default kod nomodify notrap nopeer noquery
(默认注释此条时,为不允许其他客户端来同步自己,取消注释此行可作为服务器)
restrict -6 default kod nomodify notrap nopeer noquery
# Permit all access over the loopback interface. This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict -6 ::1
# Hosts on local network are 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.. iburst (ip地址输入内网时间服务器即可)
server 0.centos.pool.ntp.org iburst
#(此项是客户端用来设置同步时间服务器的地址,iburst参数加快同步时间效率,以下三行一样)
server 1.centos.pool.ntp.org iburst
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 are 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
手动同步ntp服务器命令:ntpdate 192.168.0.0(服务器IP地址)
客户端查看同步情况命令:ntpq -p
[root@centos6-10 ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*tick.ntp.infoma .GPS. 1 u 29 64 377 203.293 -3.294 1.350
(*代表同步成功)
-stratum2-1.ntp. 89.175.20.7 2 u 19 64 377 124.897 5.803 2.650
+ntp1.flashdance 192.36.143.153 2 u 24 64 377 248.021 -2.303 4.263
+139.199.215.251 100.122.36.196 2 u 11 64 377 29.776 -0.672 2.974
[root@centos6-10 ~]# chkconfig --list ntpd
ntpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off