chrony服务器

目录

1.chrony简介

2.chrony安装配置

2.1 chrony安装及配置

非常重要:在配置之前,检查防火墙和selinux是否关闭

3.将chrony配置为其他主机的时间服务器

3.1 修改chrony配置文件

4.chronyc命令

1.chrony简介

chrony 是开源的遵循网络时间协议( ntp )的软件,让计算机系统时间与时间服务器时间一致, chrony
也可以作为时间服务器为其他主机提供服务。
ntp (网络时间协议):是 udp 123 端口。 chrony ntp 在一个计算机中只能存在一个。

2.chrony安装配置

2.1 chrony安装及配置

非常重要:在配置之前,检查防火墙和selinux是否关闭

yum install -y chrony
vim /etc/chrony.conf
[root@localhost ~]# cat /etc/chrony.conf
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server ntp.aliyun.com iburst (编写的网络时间服务器)
[root@localhost ~]# systemctl enable chronyd
[root@localhost ~]# systemctl enable chronyd
[root@localhost ~]# timedatectl status
Local time: Thu 2023-07-27 10:03:39 CST
Universal time: Thu 2023-07-27 02:03:39 UTC
RTC time: Thu 2023-07-27 02:03:39
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: yes (两个为yes即可)
NTP synchronized: yes
RTC in local TZ: no
DST active: n/a

3.chrony配置为其他主机的时间服务器

3.1 修改chrony配置文件

在提供chrony时间服务器主机的chrony配置文件中修改以下地方
服务端
1.# Allow NTP client access from local network.
allow 192.168.27.0/24(开启指定ntp客户端)
2.# Serve time even if not synchronized to a time source.
local stratum 10
3.systemctl restart chronyd
客户端
1.下载安装chrony服务
2.编写chrony配置文件
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).
server 192.168.27.120 iburst (ip是提供时间服务器的ip)
3.systemctl enable chronyd
systemctl start chronyd
检查是否同步成功
timedatectl status

4.chronyc命令

查看 ntp services
结果查看
^* :代表的是时间同步正常,同步的时间源可用
^- :代表的是可接受的源
^? :时间同步的源是不可到达的
查看 ntp serveices 是否在线
查看 ntp 的详细信息
[root@localhost ~]# chronyc activity -v
200 OK

[root@localhost ~]# chronyc tracking -v

猜你喜欢

转载自blog.csdn.net/weixin_62173637/article/details/132037959