chrony服务可以实现多台服务器的时间同步
chronyd是一个在系统后台运行的守护进程
chronyc是用来监控chronyd性能和配置其参数程序
配置文件:
/etc/chrony.conf
服务器端共享时间
[root@server ~]# vim /etc/chrony.conf ##编辑配置文件
21 # Allow NTP client access from local network.
22 allow 172.25.80.0/24 ##白名单
23
24 # Listen for commands only on localhost.
25 bindcmdaddress 127.0.0.1
26 bindcmdaddress ::1
27
28 # Serve time even if not synchronized to any NTP server.
29 local stratum 10 ##开启时间同步,设定级别
[root@server ~]# systemctl restart chronyd.service ##重启服务
[root@server ~]# systemctl enable chronyd.service
在客户端配置
[root@desktop ~]# vim /etc/chrony.conf ##编辑配置文件
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server1 172.25.80.100 iburst ##配置时间服务器地址
[root@desktop ~]# systemctl restart chronyd.service##重启进程
[root@desktop ~]# 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
|| / xxxx = adjusted offset,
|| Log2(Polling interval) -. | yyyy = measured offset,
|| \ | zzzz = estimated error.
|| | |
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 172.25.80.100 10 6 17 48 +18us[ +25us] +/- 212us
##^表示服务,*代表同步成功,?代表未同步
timedatectl:一个时间设置工具
timedatectl ##查看日期时间、时区及NTP状态
timedatectl list-timezones ##查看时区列表
timedatectl set-timezone Asia/Shanghai ##修改时区
timedatectl set-time "YYYY-MM-DD HH:MM:SS"##修改日期时间
timedatectl set-local-rtc 0 ##使用utc时间
vim /etc/adjtime
timedatectl set-local-rtc 1 ##使用本地时间
vim /etc/adjtime
原文链接:https://blog.csdn.net/xin1889/article/details/80025418