chrony时间同步服务

发布于:2022-12-24 ⋅ 阅读:(344) ⋅ 点赞:(0)

chrony配置


视频地址 哔哩哔哩

1:安装chrony软件包

[root@centos-a2 ~]# yum install chrony  #安装chrony服务,需要保证镜像源可用
[root@centos-a2 ~]# rpm -ql chrony| grep chrony.conf  #查找chrony的配置文件所在位置

2:修改配置文件

[root@centos-a2 ~]# vim /etc/chrony.conf #修改配置文件
server 时间服务器地址 iburst
[root@centos-a2 ~]# systemctl restart chronyd.service  #重启时间服务
[root@centos-a2 ~]# chronyc sources  #同步时间,chrony同步时间有一个周期,因此可能需要等待一会儿才能够同步成功,为*则表示同步成功

服务配置

同步成功

同步成功

配置文件/etc/chrony.conf部分参数说明

  • server ntp.aliyun.com iburst指定上层时间服务器地址
  • allow 192.168.0.0/16允许谁向本机同步时间
  • local stratum 10 不向任何时间服务器同步,本机作为时间源查看同步时间源
  • chronyc sources -v查看时间同步源状态
  • chronyc tracking显示系统时间的参数信息

可以使用chrony 将本机作为网络上时间服务器的客户端,和网络上的时间服务器保持一致,自动同步

可以使用chrony 将本机作为上层时间服务器,提供时间同步服务向网络上的服务器提供时间校正服务

3:本机作为时间服务器

对外提供时间同步服务

放行防火墙
[root@centos-a2 ~]# firewall-cmd --permanent --add-service=ntp 
success
[root@centos-a2 ~]# firewall-cmd --reload 
success

开启选项

[root@centos-a2 ~]# vim /etc/chrony.conf  #修改配置文件
# Allow NTP client access from local network.
allow 192.168.196.0/24   #允许向本机同步时间的网段

# Serve time even if not synchronized to a time source.
local stratum 10  #如果本机向网络时间源同步,同时也在向其他服务器提供时间服务,则开启,如果本机没有向上层服务器同步时间,将自己作为时间源可不用开启
root@centos-a2 ~]# systemctl restart chronyd.service 

本机做服务器

Centos-A1修改chrony.conf配置文件,添加Centos-A2时间服务器

[root@Centos-A1 ~]# systemctl restart chronyd.service #重启服务

同步


网站公告

今日签到

点亮在社区的每一天
去签到