centos7安装配置时间服务器

前言:

时间服务器是S/C模型服务,需要配置服务端和客户端

centos7安装配置时间服务器_第1张图片

 

NTP服务端配置:(服务端的IP为1.1.1.14)
安装ntp服务:
# yum -y install ntp
查询网络中的NTP服务器:
# ntpq -p 
No association ID's returned
修改配置文件:
# vim /etc/ntp.conf
修改如下:
#restrict default nomodify notrap nopeer noquery
restrict default nomodify

restrict 127.0.0.1
restrict ::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 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
server 127.127.1.0
重启服务:
# systemctl restart ntpd.service
# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*LOCAL(0) .LOCL. 5 l 40 64 1 0.000 0.000 0.000

NTP客户端配置:(客户端IP1.1.1.15)
# yum -y install ntp

修改配置文件:

# vim /etc/ntp.conf
server 1.1.1.14
# server 0.centos.pool.ntp.org iburst
# server 1.centos.pool.ntp.org iburst
# server 2.centos.pool.ntp.org iburst
# server 3.centos.pool.ntp.org iburst
进行时间同步:
# ntpdate -d 1.1.1.14
17 Aug 18:16:12 ntpdate[2420]: ntpdate [email protected] Fri Apr 13 12:52:28 UTC 2018 (1)
Looking for host 1.1.1.14 and service ntp
host found : iscsi-1
transmit(1.1.1.14)
receive(1.1.1.14)
transmit(1.1.1.14)
receive(1.1.1.14)
transmit(1.1.1.14)
receive(1.1.1.14)
transmit(1.1.1.14)
receive(1.1.1.14)
server 1.1.1.14, port 123
stratum 6, precision -25, leap 00, trust 000
refid [1.1.1.14], delay 0.02583, dispersion 0.00078
transmitted 4, in filter 4
reference time: df211ec3.f61979fc Fri, Aug 17 2018 18:15:31.961
originate timestamp: df211ef2.5e99e99c Fri, Aug 17 2018 18:16:18.369
transmit timestamp: df211ef2.7a146907 Fri, Aug 17 2018 18:16:18.476
filter delay: 0.02596 0.02591 0.02583 0.02591
0.00000 0.00000 0.00000 0.00000
filter offset: -0.10994 -0.10912 -0.10834 -0.10754
0.000000 0.000000 0.000000 0.000000
delay 0.02583, dispersion 0.00078
offset -0.108343

17 Aug 18:16:18 ntpdate[2420]: adjust time server 1.1.1.14 offset -0.108343 sec  (ceph默认的时间差为0.05sec)
将时间同步到硬件:
# hwclock -w
开启自动同步:
# systemctl start ntpd.service
查看服务状态:
# 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 Fri 2018-08-17 18:23:53 CST; 7s ago
Process: 2451 ExecStart=/usr/sbin/ntpd -u ntp:ntp $OPTIONS (code=exited, status=0/SUCCESS)
Main PID: 2452 (ntpd)
CGroup: /system.slice/ntpd.service
└─2452 /usr/sbin/ntpd -u ntp:ntp -g

Aug 17 18:23:53 iscsi-2 ntpd[2452]: 0.0.0.0 c01d 0d kern kernel time sync enabled
Aug 17 18:23:53 iscsi-2 ntpd[2452]: ntp_io: estimated max descriptors: 1024, initial socket boundary: 16
Aug 17 18:23:53 iscsi-2 ntpd[2452]: Listen and drop on 0 v4wildcard 0.0.0.0 UDP 123
Aug 17 18:23:53 iscsi-2 ntpd[2452]: Listen and drop on 1 v6wildcard :: UDP 123
Aug 17 18:23:53 iscsi-2 ntpd[2452]: Listen normally on 2 lo 127.0.0.1 UDP 123
Aug 17 18:23:53 iscsi-2 ntpd[2452]: Listen normally on 3 ens33 1.1.1.15 UDP 123
Aug 17 18:23:53 iscsi-2 ntpd[2452]: Listening on routing socket on fd #20 for interface updates
Aug 17 18:23:53 iscsi-2 ntpd[2452]: 0.0.0.0 c016 06 restart
Aug 17 18:23:53 iscsi-2 ntpd[2452]: 0.0.0.0 c012 02 freq_set kernel 0.000 PPM
Aug 17 18:23:53 iscsi-2 ntpd[2452]: 0.0.0.0 c011 01 freq_not_set

转载于:https://www.cnblogs.com/hlc-123/p/9496137.html

你可能感兴趣的:(centos7安装配置时间服务器)