Linux-时间同步chrony

chrony服务可以实现多台服务器的时间同步

chronyd是一个在系统后台运行的守护进程

chronyc是用来监控chronyd性能和配置其参数程序

配置文件:

/etc/chrony.conf

服务器端共享时间

[root@server ~]# vim /etc/chrony.conf                ##编辑配置文件
 21 # Allow NTP client access from local network.    
 22 allow 172.25.80.0/24                             ##白名单
 23 
 24 # Listen for commands only on localhost.
 25 bindcmdaddress 127.0.0.1
 26 bindcmdaddress ::1
 27 
 28 # Serve time even if not synchronized to any NTP server.
 29 local stratum 10                                 ##开启时间同步,设定级别
[root@server ~]# systemctl restart chronyd.service   ##重启服务
[root@server ~]# systemctl enable chronyd.service

在客户端配置

[root@desktop ~]# 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).
server1 172.25.80.100 iburst                       ##配置时间服务器地址
[root@desktop ~]# systemctl restart chronyd.service##重启进程
[root@desktop ~]# chronyc sources -v               ##查看时间信息
210 Number of sources = 1

  .-- Source mode  '^' = server, '=' = peer, '#' = local clock.
 / .- Source state '*' = current synced, '+' = combined , '-' = not combined,
| /   '?' = unreachable, 'x' = time may be in error, '~' = time too variable.
||                                                 .- xxxx [ yyyy ] +/- zzzz
||                                                /   xxxx = adjusted offset,
||         Log2(Polling interval) -.             |    yyyy = measured offset,
||                                  \            |    zzzz = estimated error.
||                                   |           |                         
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^* 172.25.80.100                10   6    17    48    +18us[  +25us] +/-  212us
##^表示服务,*代表同步成功,?代表未同步

timedatectl  : 一个时间设置工具

timedatectl                   ##查看日期时间、时区及NTP状态
timedatectl list-timezones    ##查看时区列表
timedatectl set-timezone Asia/Shanghai    ##修改时区
timedatectl set-time "YYYY-MM-DD HH:MM:SS"##修改日期时间
timedatectl set-local-rtc 0            ##使用utc时间
vim /etc/adjtime
timedatectl set-local-rtc 1            ##使用本地时间
vim /etc/adjtime


  • 4
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值