chrony时间同步软件介绍
本文分享自天翼云开发者社区《chrony时间同步软件介绍》,作者:刘****苏
chrony是网络时间协议NTP的通用实现,它可以将系统时钟和`NTP服务器同步。它支持在各种条件下包括间歇性的网络连接、严重阻塞的网络、不断变化的温度以及支持不连续的运行并且可以运行于虚机上。
本文介绍chrony工具的安装和使用,包括两个节点:一个作为时间服务器,另一个作为客户端。
执行如下命令来安装chrony:
[root@kvm ~]# yum install chrony
[root@kvm ~]# rpm -ql chrony
/etc/NetworkManager/dispatcher.d/20-chrony-dhcp
/etc/NetworkManager/dispatcher.d/20-chrony-onoffline
/etc/chrony.conf
/etc/chrony.keys
/etc/dhcp/dhclient.d/chrony.sh
/etc/logrotate.d/chrony
/etc/sysconfig/chronyd
/usr/bin/chronyc
/usr/lib/.build-id
/usr/lib/.build-id/38
/usr/lib/.build-id/38/1d3a324ce66865ba879dfa43d49e0e0c1e2c41
/usr/lib/.build-id/43
/usr/lib/.build-id/43/444c816fcf0802c43011f282afaf9feded4c56
/usr/lib/systemd/ntp-units.d/50-chronyd.list
/usr/lib/systemd/system/chrony-dnssrv@.service
/usr/lib/systemd/system/chrony-dnssrv@.timer
/usr/lib/systemd/system/chrony-wait.service
/usr/lib/systemd/system/chronyd.service
/usr/libexec/chrony-helper
/usr/sbin/chronyd
/usr/share/doc/chrony
/usr/share/doc/chrony/FAQ
/usr/share/doc/chrony/NEWS
/usr/share/doc/chrony/README
/usr/share/doc/chrony/ntp2chrony.py
/usr/share/licenses/chrony
/usr/share/licenses/chrony/COPYING
/usr/share/man/man1/chronyc.1.gz
/usr/share/man/man5/chrony.conf.5.gz
/usr/share/man/man8/chronyd.8.gz
/var/lib/chrony
/var/lib/chrony/drift
/var/lib/chrony/rtc
/var/log/chrony
如下所示为配置文件:
[root@kvm ~]# cat /etc/chrony.conf
pool 2.centos.pool.ntp.org 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.
makestep 1.0 3
# Enable kernel synchronization of the real-time clock (RTC).
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 0/0
# Serve time even if not synchronized to a time source.
local stratum 10
# Specify file containing keys for NTP authentication.
keyfile /etc/chrony.keys
# Get TAI-UTC offset and leap seconds from the system tz database.
leapsectz right/UTC
# Specify directory for log files.
logdir /var/log/chrony
# Select which information is logged.
#log measurements statistics tracking
其中:
pool:为外部时钟源地址
rtcsync:开启硬件时钟的同步机制,linux内核每11分钟同步一次系统时钟到硬件时钟
local stratum 10:当外部时钟源不可用的时候,以本机时钟为准继续提供服务
allow 0/0:允许的客户端的cidr
启动服务后查看状态:
[root@kvm ~]# systemctl start chronyd
[root@kvm ~]#
[root@kvm ~]#
[root@kvm ~]# systemctl status chronyd
● chronyd.service - NTP client/server
Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2023-09-08 19:02:50 CST; 2min 43s left
Docs: man:chronyd(8)
man:chrony.conf(5)
Process: 11542 ExecStopPost=/usr/libexec/chrony-helper remove-daemon-state (code=exited, status=0/SUCCESS)
Process: 11552 ExecStartPost=/usr/libexec/chrony-helper update-daemon (code=exited, status=0/SUCCESS)
Process: 11547 ExecStart=/usr/sbin/chronyd $OPTIONS (code=exited, status=0/SUCCESS)
Main PID: 11550 (chronyd)
Tasks: 1 (limit: 52427)
Memory: 924.0K
CGroup: /system.slice/chronyd.service
└─11550 /usr/sbin/chronyd
Sep 08 19:02:50 kvm chronyd[11550]: chronyd version 4.2 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +NTS +SECHASH +IPV6 +DEBUG)
Sep 08 19:02:50 kvm chronyd[11550]: Frequency 1.633 +/- 0.046 ppm read from /var/lib/chrony/drift
Sep 08 19:02:50 kvm chronyd[11550]: Using right/UTC timezone to obtain leap second data
Sep 08 19:02:50 kvm systemd[1]: Started NTP client/server.
Sep 08 19:02:55 kvm chronyd[11550]: Selected source 36.110.233.85 (2.centos.pool.ntp.org)
Sep 08 19:02:55 kvm chronyd[11550]: System clock wrong by -791.549636 seconds
Sep 08 18:49:44 kvm chronyd[11550]: System clock was stepped by -791.549636 seconds
Sep 08 18:49:44 kvm chronyd[11550]: System clock TAI offset set to 37 seconds
Sep 08 18:50:49 kvm chronyd[11550]: Selected source 119.28.206.193 (2.centos.pool.ntp.org)
Sep 08 18:54:07 kvm chronyd[11550]: Source 81.16.177.123 replaced with 78.46.102.180 (2.centos.pool.ntp.org)
[root@kvm ~]#
[root@kvm ~]# netstat -tunlp |grep chrony
udp 0 0 0.0.0.0:123 0.0.0.0:* 11550/chronyd
udp 0 0 127.0.0.1:323 0.0.0.0:* 11550/chronyd
udp6 0 0 ::1:323 :::* 11550/chronyd
[root@kvm ~]#
[root@kvm ~]# chronyc sources -v
.-- Source mode '^' = server, '=' = peer, '#' = local clock.
/ .- Source state '*' = current best, '+' = combined, '-' = not combined,
| / 'x' = may be in error, '~' = too variable, '?' = unusable.
|| .- xxxx [ yyyy ] +/- zzzz
|| Reachability register (octal) -. | xxxx = adjusted offset,
|| Log2(Polling interval) --. | | yyyy = measured offset,
|| \ | | zzzz = estimated error.
|| | | \
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^- 79.133.44.136 1 6 377 56 -10ms[ -10ms] +/- 138ms
^- electrode.felixc.at 2 6 33 55 +17ms[ +17ms] +/- 119ms
^* 119.28.206.193 2 6 377 60 +1706us[+2327us] +/- 40ms
^+ 36.110.233.85 2 6 377 58 -1324us[-1324us] +/- 68ms
chrony守护进程监听在udp协议的123和323端口。
客户端节点上安装好chrony后,修改配置文件如下所示:
[root@node1 ~]# cat /etc/chrony.conf
server 172.24.21.221 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.
makestep 3600 3
# Enable kernel synchronization of the real-time clock (RTC).
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 192.168.0.0/16
# Serve time even if not synchronized to a time source.
#local stratum 10
# Specify file containing keys for NTP authentication.
#keyfile /etc/chrony.keys
# Specify directory for log files.
logdir /var/log/chrony
# Select which information is logged.
#log measurements statistics tracking
查看状态:
[root@node1 ~]# 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
|| Reachability register (octal) -. | xxxx = adjusted offset,
|| Log2(Polling interval) --. | | yyyy = measured offset,
|| \ | | zzzz = estimated error.
|| | | \
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 172.24.21.221 3 6 377 37 -7753ns[ +140us] +/- 29ms
chrony默认是采用连续同步的方式来同步时钟的,并非采用跳变的方式。
chrony时间同步软件介绍的更多相关文章
- CentOS7.4 chrony时间同步服务器部署(替代NTPD)
Chrony是一个开源的自由软件,它能保持系统时钟与时钟服务器(NTP)同步,让时间保持精确. 它由两个程序组成:chronyd和chronyc. chronyd是一个后台运行的守护进程,用于调整内核 ...
- Linux 时间同步 05 chrony时间同步
Linux 时间同步 05 chrony时间同步 目录 Linux 时间同步 05 chrony时间同步 chrony 的优势: chrony包介绍 安装chrony 配置与外部时间服务器进行时间同步 ...
- Chrony时间同步服务
概: 网络时间协议(Network Time Protocol,NTP)是用于网络时间同步的协议.提供NTP时间同步服务的软件有很多,这里采用Chrony软件来实现时间同步 chrony 的优势: ...
- 软件介绍(apache lighttpd nginx)
一.软件介绍(apache lighttpd nginx) 1. lighttpd Lighttpd是一个具有非常低的内存开销,cpu占用率低,效能好,以及丰富的模块等特点.lighttpd是众多 ...
- Visual paradigm软件介绍
Visual paradigm软件介绍 说起Visual Paradigm你可能并不陌生,因为此前有一款功能强大的UML软件叫Visual Paradigm for UML,在这款软件在v11.1的时 ...
- chrony时间同步 服务端 客户端 安装配置
chrony时间同步 服务端 客户端 安装配置 原创内容http://www.cnblogs.com/elvi/p/7658021.html #!/bin/sh #运行环境 centos7 #chro ...
- sumatrapdf 软件介绍
sumatrapdf 软件介绍 介绍 支持PDF, ePub, Mobi, XPS, DjVu, CHM, CBZ 和 CBR格式的电子文件 仅支持Windows,原因见官网论坛 绿色版,小巧,于此 ...
- 一.软件介绍(apache lighttpd nginx)
一.软件介绍(apache lighttpd nginx) 1. lighttpd Lighttpd是一个具有非常低的内存开销,cpu占用率低,效能好,以及丰富的模块等特点.lighttpd是众多 ...
- Linux基础学习-chrony时间同步服务
Chrony时间同步 NTP(Network Time Protocol,网络时间协议)是用来使网络中的各个计算机时间同步的一种协议.它的用于是把计算机的时钟同步到世界协调时UTC,其精度在局域网内可 ...
- Java机器学习软件介绍
Java机器学习软件介绍 编写程序是最好的学习机器学习的方法.你可以从头开始编写算法,但是如果你要取得更多的进展,建议你采用现有的开源库.在这篇文章中你会发现有关Java中机器学习的主要平台和开放源码 ...
随机推荐
- DICOM 生成dcm文件
using Dicom; using Dicom.Imaging; using Dicom.IO.Buffer; using System; using System.Collections.Gene ...
- HERS: Homomorphically Encrypted Representation Search-2020:学习
阅读"HERS: Homomorphically Encrypted Representation Search-2020",记录笔记. 摘要 本文介绍了一种针对加密图像的搜索方法 ...
- python3 使用中的问题
gmpy2 GMP(GNU Multiple Precision Arithmetic Library,即GNU高精度算术运算库),它是一个开源的高精度运算库,其中不但有普通的整数.实数.浮点数的高精 ...
- 安装K8s集群
因阿里云加速服务调整,镜像加速服务自2024年7月起不再支持,拉取镜像,下载网络插件等操作,需要国际联网访问DockerHub. 安装全过程均使用ROOT权限. 1.安装前准备工作 这里采用3台Cen ...
- 在阿里云ECS上一键部署DeepSeek-R1
DeepSeek-R1 是一款开源模型,也提供了 API(接口)调用方式.据 DeepSeek介绍,DeepSeek-R1 后训练阶段大规模使用了强化学习技术,在只有极少标注数据的情况下提升了模型推理 ...
- Q:linux(群晖)修改网卡速率
问题:群晖速度莫名其妙变成了1MB/s左右,查看网络状态 网卡配置变成 全双工10Mb/s 解决方法 首先开启ssh登录权限 1.控制面板 – 终端机和SNMP里,开启SSH功能. 2.通过ssh连接 ...
- PC端自动化测试实战教程-1-pywinauto 环境搭建(详细教程)
1.简介 之前总有人在群里或者私信留言问:Windows系统安装的软件如何自动化测试呢?因为没有接触过或者遇到过,所以说实话宏哥当时也不清楚怎么实现,怎么测试.然而在一次偶然的机会接触到了Python ...
- TCP 和 UDP 可以使用同一个端口吗?
文档地址:https://mp.weixin.qq.com/s/3fMZN_LidCi5fiD16nNWWA
- Luogu P3959 宝藏 题解 [ 紫 ] [ 状压 dp ] [ 二项式定理 ]
宝藏:一个对着蓝书代码调都能调两个小时的大毒瘤,但是思路还是很值得借鉴的,有普通状压和三进制状压两种做法,或者暴搜剪枝也可以(这里不介绍暴搜剪枝做法). 普通状压做法 观察到 \(n\le 12\), ...
- 牛客题解 | 单组_A+B
题目 题目链接 解题思路 输入两个数字,输出它们的和. 代码 #include <iostream> using namespace std; int main(void) { ios:: ...