RHCE8.0-时间服务器

chrony时间服务器

能保持系统时间与时间服务器(NTP)同步,让时间始终保持同步。相对NTP时间同步软件,速度更快、配置和依赖都更简单
Chrony有两个核心组件,分别是:chronyd:是守护进程,主要用于调整内核中运行的系统时间和时间服务器同步。它确定计算机增减时间的比率,并对此进行调整补偿。chronyc:提供一个用户界面,用于监控性能并进行多样化的配置。它可以在chronyd实例控制的计算机上工作,也可以在一台不同的远程计算机上工作。

配置文件参数说明

#使用 pool.ntp.org 项目中的公共服务器。以server开,理论上想添加多少时间服务器都可以。
server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst

# 根据实际时间计算出服务器增减时间的比率,然后记录到一个文件中,在系统重启后为系统做出最佳时间补偿调整。
driftfile /var/lib/chrony/drift

# 如果系统时钟的偏移量大于1秒,则允许系统时钟在前三次更新中步进。
makestep 1.0 3

# 启用实时时钟(RTC)的内核同步。
rtcsync

# 通过使用 hwtimestamp 指令启用硬件时间戳
#hwtimestamp *

# Increase the minimum number of selectable sources required to adjust the system clock.
#minsources 2

# 指定 NTP 客户端地址,以允许或拒绝连接到扮演时钟服务器的机器
#allow 192.168.0.0/16

# Serve time even if not synchronized to a time source.
#local stratum 10

# 指定包含 NTP 身份验证密钥的文件。
#keyfile /etc/chrony.keys

# 指定日志文件的目录。
logdir /var/log/chrony

# 选择日志文件要记录的信息。
# Select which information is logged.
#log measurements statistics tracking

配置

服务端
1、查看安装的chrony包
[root@redhat ~]# rpm -aq | grep chron 
boost-chrono-1.66.0-6.el8.x86_64
chrony-3.5-1.el8.x86_64

2、编辑配置文件
[root@redhat ~]# vim /etc/chrony.conf 
server ntp.aliyun.com iburst  同步的参考
allow 192.168.16.0/24

3、重启服务
[root@redhat ~]# systemctl restart chronyd.service 

客户端:
1、编辑配置文件
[root@node1 ~]# vim /etc/chrony.conf 
server 192.168.16.100 iburst

2、重启服务及开机自启
[root@node1 ~]# systemctl restart chronyd.service 
[root@node1 ~]# systemctl enable chronyd

常用命令

查看时间同步源		chronyc sources -v
立即手工同步 		chronyc -a makestep
查看时间同步源状态 	chronyc sourcestats -v

设置硬件时间
  硬件时间默认为UTC	timedatectl set-local-rtc 1
  启用NTP时间同步 	timedatectl set-ntp yes
  校准时间服务器		chronyc tracking
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值