chrony服务

利用chrony,配置linux1为其他linux主机提供NTP服务。
在这里插入图片描述
//使用for循环给所

[root@linux1 ~]# for i in {1..9};do ssh root@10.4.220.10$i yum install -y chrony ;done

[root@linux1 ~]# vi /etc/chrony.conf //修改服务端配置文件

  1 # Use public servers from the pool.ntp.org project.
  2 # Please consider joining the pool (https://www.pool.ntp.org/join.html).
  3 #pool 2.rocky.pool.ntp.org iburst  //取消注释
  4 server 10.4.220.101 ibutst  //添加这段
  5
  6 # Use NTP servers from DHCP.
  7 sourcedir /run/chrony-dhcp
  8
  9 # Record the rate at which the system clock gains/losses time.
 10 driftfile /var/lib/chrony/drift
 11
 12 # Allow the system clock to be stepped in the first three updates
 13 # if its offset is larger than 1 second.
 14 makestep 1.0 3
 15
 16 # Enable kernel synchronization of the real-time clock (RTC).
 17 rtcsync
 18
 19 # Enable hardware timestamping on all interfaces that support it.
 20 #hwtimestamp *
 21
 22 # Increase the minimum number of selectable sources required to adjust
 23 # the system clock.
 24 #minsources 2
 25
 26 # Allow NTP client access from local network.
 27 #allow 192.168.0.0/16
 28 allow 10.4.220.0/24  //添加
 29
 30 # Serve time even if not synchronized to a time source.
 31 local stratum 10  //取消注释

[root@linux2 ~]# vi /etc/chrony.conf //配置客户端

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (https://www.pool.ntp.org/join.html).
#pool 2.rocky.pool.ntp.org iburst  //取消注释
server 10.4.220.101 iburst  //添加;注:客户端只用修改这里

# Use NTP servers from DHCP.
sourcedir /run/chrony-dhcp

# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift

//利用for循环把配置文件发送到别的主机

[root@linux2 ~]# for i in {3..9};do scp /etc/chrony.conf root@10.4.220.10$i:/etc/chrony.conf ;done

[root@linux1 ~]# firewall-cmd --zone=public --add-port=123/udp --permanent //放行端口
[root@linux1 ~]# firewall-cmd --reload //刷新规则
//利用for循环重启所有主机的服务

[root@linux1 ~]# for i in {1..9};do ssh root@10.4.220.10$i systemctl restart chronyd.service ;done

//验证
[root@linux1 ~]# chronyc clients //查询同步主机
在这里插入图片描述

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值