chrony时间服务配置

1、chrony安装

yum  -y install  chrony

2、配置文件

# /etc/chrony.conf

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).

###本机作为源ntp服务器
server 127.127.1.0  iburst

###同步的ntp服务器地址
server 172.16.101.11 iburst    prefer minpoll 6 maxpoll 10     ###(iburst在启动的俩秒以内快速poll服务器4次来矫正当前系统时间,prefer优先使用该ntp服务器进行同步,minpoll最短轮询周期是2的6次方秒,maxpol最长轮询周期是2的10次方秒)
server 172.16.101.12 iburst  


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

# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.(如果时间服务器和系统时间相差1秒,那么会再在下3个时钟更新中追上时间服务器)
makestep 1.0 3
#最大调整频率ppm,最大值为100000ppm,每秒调整100ms。(ppm百万分之一)
maxslewrate  100000
#与root服务器的最大时间差,单位s,超过这个时间将不做调整
maxdistance  1000.0
# Enable kernel synchronization of the real-time clock (RTC).(每隔11分钟将系统时钟同步到主板的硬件时钟去)
rtcsync

# Enable hardware timestamping on all interfaces that support it.
#hwtimestamp *

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

# Allow NTP client access from local network.
###允许哪些服务器过来同步
allow all

# Serve time even if not synchronized to a time source.
###表示时间来源与原子钟的距离,数值越大,说明精度越低,一般设置是1-15(一般是递增的)。如果不设置则表示忽略。
#local stratum 1 orphan
# Specify file containing keys for NTP authentication.
#keyfile /etc/chrony.keys

# Specify directory for log files.
logdir /var/log/chrony

3、常用命令

命令:
chronyc  sources  -v
查看ntp服务配置情况,可以看到本地源和同步源是否可用
chronyc  activity
查看ntp服务响应情况
chronyc -a makestep
立即手工同步
chronyc sourcestats -v
查看时间同步源状态


设置硬件时间
硬件时间默认为UTC:
timedatectl set-local-rtc 1
启用NTP时间同步:
timedatectl set-ntp yes
校准时间服务器:
chronyc tracking

查看当前时区
timedatectl
查看所有可用时区
timedatectl list-timezones
查看亚洲的时区
timedatectl list-timezones |  grep  -E "Asia/S.*"
设置上海时区
timedatectl set-timezone Asia/Shanghai
设置完时区后,强制同步下系统时钟:
chronyc -a makestep

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值