chrony 是网络时间协议(NTP)的通用实现。

chrony 包含两个程序:chronyd 是一个可以在启动时启动的守护程序。chronyc 是一个命令行界面程序,用于监视 chronyd 的性能并在运行时更改各种操作参数。

与其它时间同步软件的对比:https://chrony.tuxfamily.org/comparison.html

一、安装与配置

yum -y install chrony

systemctl enable chronyd
systemctl start chronyd vim /etc/chrony.conf

chrony.conf 默认配置

# 使用 pool.ntp.org 项目中的公共服务器。以server开,理论上想添加多少时间服务器都可以。
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
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 # 根据实际时间计算出服务器增减时间的比率,然后记录到一个文件中,在系统重启后为系统做出最佳时间补偿调整。
# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift # 如果系统时钟的偏移量大于1秒,则允许系统时钟在前三次更新中步进。
# Allow the system clock to be stepped in the first three updates if its offset is larger than 1 second.
makestep 1.0 3 # 启用实时时钟(RTC)的内核同步。
# Enable kernel synchronization of the real-time clock (RTC).
rtcsync # 通过使用 hwtimestamp 指令启用硬件时间戳
# 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 # 指定 NTP 客户端地址,以允许或拒绝连接到扮演时钟服务器的机器
# 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 # 指定包含 NTP 身份验证密钥的文件。
# 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

二、使用

ntp 服务器:https://www.cnblogs.com/jhxxb/p/10579816.html

1.服务端配置

chrony.conf 修改两处

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server s1a.time.edu.cn iburst
server ntp.aliyun.com iburst # Allow NTP client access from local network.
allow 192.168.8.0/24

开启同步

systemctl enable chronyd
systemctl restart chronyd # 查看时间同步状态
timedatectl status
# 开启网络时间同步
timedatectl set-ntp true

2.客户端配置

chrony.conf 修改两处

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 192.168.8.5 iburst # Allow NTP client access from local network.
allow 192.168.8.5

开启同步

systemctl enable chronyd
systemctl restart chronyd # 查看时间同步状态
timedatectl status
# 开启网络时间同步
timedatectl set-ntp true

三、命令

chronyc 用法

# 查看 ntp_servers
chronyc sources -v # 查看 ntp_servers 状态
chronyc sourcestats -v # 查看 ntp_servers 是否在线
chronyc activity -v # 查看 ntp 详细信息
chronyc tracking -v

修改时区

# 查看日期时间、时区及 NTP 状态
timedatectl # 查看时区列表
timedatectl list-timezones
timedatectl list-timezones | grep -E "Asia/S.*" # 修改时区
timedatectl set-timezone Asia/Shanghai # 修改日期时间(可以只修改其中一个)
timedatectl set-time "2019-09-19 15:50:20" # 开启 NTP
timedatectl set-ntp true/flase

https://chrony.tuxfamily.org/

https://www.linuxprobe.com/centos7-chrony-time.html

https://www.zfl9.com/chrony.html

Linux 时间同步 Chrony的更多相关文章

  1. Linux 时间同步 05 chrony时间同步

    Linux 时间同步 05 chrony时间同步 目录 Linux 时间同步 05 chrony时间同步 chrony 的优势: chrony包介绍 安装chrony 配置与外部时间服务器进行时间同步 ...

  2. Linux 时间同步 01 简介

    Linux 时间同步 01 简介 目录 Linux 时间同步 01 简介 时间同步 公共NTP服务器地址及IP 系统时间相关文件 时间同步 大数据产生与处理系统是各种计算设备集群的,计算设备将统一.同 ...

  3. Linux时间同步方式记录

    Linux时间同步 部署Hadoop集群,遇到各个linux服务器的时间不同步的问题,于是研究了一下linux的时间同步方式,特将同步方式,总结如下: A. 前提条件 a)         网络是连通 ...

  4. linux时间同步,ntpd、ntpdate

    linux时间同步,ntpd.ntpdate 在Windwos中,系统时间的设置很简单,界面操作,通俗易懂.而且设置后,重启,关机都没关系.系统时间会自动保存在Bios的时钟里面,启动计算机的时候,系 ...

  5. linux 时间同步的2种方法(转)

    linux 时间同步的2种方法 张映 发表于 2012-10-23 分类目录: 服务器相关 标签:linux, ntp, 同步, 时间服务器 由于硬件的原因,机器或多或少的根标准时间对不上,一个月的误 ...

  6. 时间同步chrony

          时间同步chrony [root@compute02 ~]# yum install chrony   编辑配置文件 将sever区块下的内容修改为时间服务器的地址 .此处可以写局域网内的 ...

  7. Linux 时间同步 03 ntpdate时间同步

    Linux 时间同步 03 ntpdate时间同步 目录 Linux 时间同步 03 ntpdate时间同步 安装ntpdate 修改/etc/sysconfig/ntpdate 使用ntpdate手 ...

  8. Linux 时间同步 04 ntp时间同步

    Linux 时间同步 04 ntp时间同步 目录 Linux 时间同步 04 ntp时间同步 安装ntp 配置与外部时间服务器进行时间同步的客户端主机 配置其他客户端与以上客户端主机时间同步 验证查看 ...

  9. Linux 时间同步 02 ntpd、ntpdate的区别

    Linux 时间同步 02 ntpd.ntpdate的区别 目录 Linux 时间同步 02 ntpd.ntpdate的区别 [一]这样做不安全. [二]这样做不精确. [三]这样做不够优雅. ntp ...

随机推荐

  1. stm32 PWM

    脉冲宽度调制是利用微处理器的数字输出来对模拟电路进行控制的一种非常有效的技术 高级定时器可以同时产生多达7路的PWM输出 而通用定时器也能同时产生多达4路的PWM输出 脉冲宽度调制模式可以产生一个由T ...

  2. Kubernetes的核心技术概念和API对象

    Kubernetes的核心技术概念和API对象 API对象是K8s集群中的管理操作单元.K8s集群系统每支持一项新功能,引入一项新技术,一定会新引入对应的API对象,支持对该功能的管理操作.例如副本集 ...

  3. python基础应用---列表应用

    列表:列表用[]来表示 names = ['wang', 'yuan', 'yang', 'china', 'french', 'wang'] #列表增加 names.append('zhang') ...

  4. mongodb索引 单键索引

    单键索引是最普通的索引,比如一条记录,形式为{x:1,y:2,z:3},我们在x上建立索引,之后就可以以x为条件进行查询,与_id索引不同,单键索引不会自动创建 创建索引 > db.test2. ...

  5. java学习笔记13-重写与重载

    重写 重写是子类对父类允许访问的方法实现过程进行重新编写,返回值和参数都不能变. 重写方法不能抛出新的检查异常和比被重写方法更加宽泛的异常 访问权限不能比被重写方法低 声明为final的方法不能被重写 ...

  6. JAVA遇见HTML——JSP篇(JSP内置对象下)

    request.getSession() 网上资料解释: request只能存在于一次访问里 session对象的作用域为一次会话 session长驻在服务器内存里,session有id标识,一个se ...

  7. python_json模块和pickle模块

    json 优点:所有语言通用:缺点:只能序列化基本的数据类型list/dict/int... json格式中,字符串必须是双引号,字符都是小写. 序列化: import json v = [12,3, ...

  8. 2018HDU多校联赛第六场 6373 Pinball——水题&&物理题

    题意 给定一个斜面,从某处让一个小球作自由落体运动,求小球与斜面的碰撞次数(假设都为弹性碰撞). 分析 题图如下,x轴.y轴是虚拟的. 根据高中物理的套路,沿斜面方向分解重力加速度即可. #inclu ...

  9. BZOJ 3052/Luogu P4074 [wc2013]糖果公园 (树上带修莫队)

    题面 中文题面,难得解释了 BZOJ传送门 Luogu传送门 分析 树上带修莫队板子题... 开始没给分块大小赋初值T了好一会... CODE #include <bits/stdc++.h&g ...

  10. P2634 [国家集训队]聪聪可可 点分治

    思路:点分治 提交:1次 题解: 不需要什么容斥...接着板子题说: 还是基本思路:对于一颗子树,与之前的子树做贡献. 我们把路径的权值在\(\%3\)意义下分类,即开三个桶\(c[0],c[1],c ...