CHRONY 时间服务器

时间同步服务chrony

  • ntp network time Protocol之前使用的同步协议
  • chrony ntp协议的实现,兼容网络中的ntp服务(centos7之后就不再使用ntp,转而使用chrony)
  • rpm -ql chrony
  • 主要配置文件 /etc/chrony.conf
  • systemctl status chronyd (查看是否启动)
  • 监听utp的323端口,chrony时间同步
  • chronyc工具内部有很多包含的命令,可以用来设置配置文件,包括添加时间服务器,查看同步情况,删除时间服务器,查看有几个时间服务器等等说
  • 配置文件中 (centos7)server 服务器地址 iburst ,可多个,默认的是香港的地址 (centos8)poor 服务器地址 iburst(ntp.aliyun.com 阿里的时间服务器)

    内部配置

  • 搭建一个时间同步的机器,与互联网的时间服务器同步,并让内部服务器获取当前服务器的时间

    (服务端)

  • 需要更改配置文件中的服务端allow 允许别人利用我的时间同步
  • 设置时间服务器的时间从哪里获取,比如从阿里云:server ntp.aliyun.com iburst
  • 当网络时间不可用的时候时间服务器启用本地硬件时间为基准: local stratum 10
  • 设置完成后重启时间服务:systemctl restart chronyd

    (客户端)

  • 需要更改配置文件中从局域网的时间服务器来进行时间同步:server 192.168.47.25 iburst
  • 设置完成后重启时间服务:systemctl restart chronyd
  • ntpdate ip 立刻与目标主机同步时间
  • chronyc 命令 然后 sources -v 查看与目标同步的情况

    (测试)

  • date -s '-1 year' 设置当前时间减少一年
  • 如果需要比较急观察就重启服务后过一会儿时间就会同步
  • 阿里提供的时间同步服务器:ntp.aliyun.com~ntp7.aliyun.com

    编写脚本来更改配置文件

  • sed -ri 's/^#s.*t$/ server 192.168.47.25 iburst/g' /etc/chrony.conf ;systemctl restart chronyd

猜你喜欢

转载自www.cnblogs.com/Justin0717/p/11845206.html