Network Time Protocol(NTP),NTP协议由在用户空间中运行的守护程序实现,即ntp和chrony。
RHEL7和RHEL8同步系统时间区别
RHEL7中,可以选择ntp或chrony,在RHL8中,不支持ntp,使用chronyd守护进程来实现NTP。
chrony和ntp之间的差异
1.ntp服务器在控制客户端访问方式默认响应来自任何地址的请求,相对不安全
2.chronyd默认不允许访问,要想提供时间同步服务端需要在allow中指定
3.ntpd和chrony在系统时钟校正方面的默认行为也不同
4.客户端同步的工作方式有差异
RHEL8配置时间同步服务
1.配置软件仓库(dnf源)
2.了解配置文件(man 5 xxx.conf)
3.启动服务,开机自启动
时间同步服务器端
[xiaoshuai.zhu@rhel8 ~]$ sudo dnf install chrony -y
[xiaoshuai.zhu@rhel8 ~]$ sudo vim /etc/chrony.conf
pool 2.rhel.pool.ntp.org iburst
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
**pool ntp1.aliyun.com iburst**
# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift
# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.
makestep 1.0 3
# Enable kernel synchronization of the real-time clock (RTC).
rtcsync
# Enable hardware timestamping on all interfaces that support it.
#hwtimestamp *
# Increase the minimum number of selectable sources required to adjust
# the system clock.
#minsources 2
# Allow NTP client access from local network.
#allow 192.168.0.0/16
# Serve time even if not synchronized to a time source.
#local stratum 10
# Specify file containing keys for NTP authentication.
keyfile /etc/chrony.keys
# Get TAI-UTC offset and leap seconds from the system tz database.
leapsectz right/UTC
# Specify directory for log files.
logdir /var/log/chrony
# Select which information is logged.
#log measurements statistics tracking
[xiaoshuai.zhu@rhel8 ~]$ sudo systemctl start chronyd.service && sudo systemctl enable chronyd.service
[xiaoshuai.zhu@rhel8 ~]$ sudo chronyc sources -v
210 Number of sources = 1
.-- Source mode '^' = server, '=' = peer, '#' = local clock.
/ .- Source state '*' = current synced, '+' = combined , '-' = not combined,
| / '?' = unreachable, 'x' = time may be in error, '~' = time too variable.
|| .- xxxx [ yyyy ] +/- zzzz
|| Reachability register (octal) -. | xxxx = adjusted offset,
|| Log2(Polling interval) --. | | yyyy = measured offset,
|| \ | | zzzz = estimated error.
|| | | \
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 120.25.115.20 2 6 17 3 -207us[-1457us] +/- 16ms