centos8使用chrony作为NTP服务器

导读Centos8不在直接使用ntp,而是使用chrony作为时间同步,chrony既可以当服务器端广播时间,又可以作为客户端同步时间

centos8使用chrony作为NTP服务器centos8使用chrony作为NTP服务器

安装

sudo dnf install chrony -y
sudo yum install chrony -y

Centos8使用firewalld服务对防火墙进行管理。放行ntp服务(123/udp)

firewall-cmd --add-service=ntp --permanent && firewall-cmd --reload

作为服务器端

配置chrony服务端

sudo vim /etc/chrony.conf

删除配置自带的NTP服务器。换成国内阿里云的NTP服务器地址。Linux就该这么学

添加上游NTP服务器

server time1.aliyun.com iburst     
server time2.aliyun.com iburst
server time3.aliyun.com iburst

允许 192.168.1.0/24 内的客户端通过这台服务器获取时间

allow 192.168.1.0/24 

配置无误后,重启chrony服务,并配置开机自启动:

systemctl restart chronyd.service
systemctl enable chronyd.service

使用ss -tlunp | grep chrony或者 lsof -i:123命令检查chrony服务使用的123/udp端口是否启动成功

作为客户端

同样安装,然后修改客户端chrony配置文件

sudo 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).
# pool 2.centos.pool.ntp.org iburst 

#添加NTP服务器

server time1.aliyun.com iburst     
server time2.aliyun.com iburst
server time3.aliyun.com iburst

如果有自建的chrony客户端也可以自行配置

server 192.168.1.30 iburst

重启chrony客户端服务,重启chrony服务,并配置开机自启动:

systemctl restart chronyd.service && systemctl enable chronyd.service --now

查看同步状态

chronyc sources -v
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值