centos系统chrony时间同步

概要

chrony 是网络时间协议(Network Time Protocol )的通用实现。它不但可以提供保持系统时间与 NTP 时钟服务器同步的服务,还能作为 NTP 服务器对其他服务器提供时间同步服务。

chrony 有两个核心组件:

  • chronyd  守护进程,主要用于调整内核中运行的系统时间和时间服务器同步
  • chronyc  命令行界面程序,让用户能够对 chronyd 的性能进行监控以及改变各种参数

安装

yum install chrony -y

配置

# 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
server 192.168.0.1 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 192.168.0.0/24

# 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

查看

chronyc sources -v
timedatectl

timedatectl时间设置命令

管理系统时间
timedatectl +   

  • status       ##显示当前时间信息
  • set-time      ##设定当前时间
  • set-timezone    ##设定当前时区
  • set-local-rtc 0|1   ##设定是否使用utc时间
  • list-timezones   ##查看支持的所有时区

一键命令

按需要修改

#服务器需要添加
sed -i '$a\local stratum 10' /etc/chrony.conf
sed -i '$a\allow' /etc/chrony.conf 
#客户端需要添加,修改对应服务器ip
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i '/^SELINUX=/cSELINUX=disabled' /etc/selinux/config
getenforce
yum install chrony -y
sed -i '$a\server 192.168.0.2 iburst' /etc/chrony.conf
sed -i 's/^server 0.centos.pool.ntp.org iburst/#server 0.centos.pool.ntp.org iburst/g' /etc/chrony.conf
sed -i 's/^server 1.centos.pool.ntp.org iburst/#server 1.centos.pool.ntp.org iburst/g' /etc/chrony.conf
sed -i 's/^server 2.centos.pool.ntp.org iburst/#server 2.centos.pool.ntp.org iburst/g' /etc/chrony.conf
sed -i 's/^server 3.centos.pool.ntp.org iburst/#server 3.centos.pool.ntp.org iburst/g' /etc/chrony.conf
systemctl restart chronyd
systemctl enable chronyd
chronyc sources -v
sleep 4
chronyc sources -v
timedatectl

参考文章:https://blog.csdn.net/weixin_43936969/article/details/102628813

centos系统chrony时间同步的更多相关文章

  1. 让CentOS系统时间同步

    CentOS系统时间同步的步骤如下: 新装的CentOS系统服务器可能设置了错误的,需要调整时区并调整时间. 如下是CentOS系统使用NTP来从一个时间服务器同步cp /usr/share/zone ...

  2. 简单几步让CentOS系统时间同步(转)

    在使用CentOS系统的时候,我们可能会遇到时间不准的问题,那我们如何解决这个我问题呢,下面就来教大家一个CentOS系统时间同步的方法,希望大家可以解决自己所存在的疑问. CentOS系统时间同步的 ...

  3. 使用ntp从时间同步服务器更新centos系统时间的方法

    CentOS系统时间同步的步骤如下: 复制代码 代码如下: cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtimentpdate us.pool.ntp ...

  4. CentOS系统时间同步(NTP)

    CentOS系统时间同步的步骤如下: 新装的CentOS系统服务器可能设置了错误的,需要调整时区并调整时间. 如下是CentOS系统使用NTP来从一个时间服务器同步把当前时区调整为上海就是+8区,想改 ...

  5. 简单几步让CentOS系统时间同步

    在使用CentOS系统的时候,我们可能会遇到时间不准的问题,那我们如何解决这个我问题呢,下面就来教大家一个CentOS系统时间同步的方法,希望大家可以解决自己所存在的疑问. CentOS系统时间同步的 ...

  6. CentOS7.4 chrony时间同步服务器部署(替代NTPD)

    Chrony是一个开源的自由软件,它能保持系统时钟与时钟服务器(NTP)同步,让时间保持精确. 它由两个程序组成:chronyd和chronyc. chronyd是一个后台运行的守护进程,用于调整内核 ...

  7. linux服务之NTP及chrony时间同步

    博客园 首页 联系 管理   linux服务之NTP及chrony时间同步   一.NTP时间同步 NTP(Network Time Protocol,网络时间协议)是由RFC 1305定义的时间同步 ...

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

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

  9. Chrony时间同步服务

    概:  网络时间协议(Network Time Protocol,NTP)是用于网络时间同步的协议.提供NTP时间同步服务的软件有很多,这里采用Chrony软件来实现时间同步 chrony 的优势:  ...

  10. centos系统时间与硬件时间不一致

    centos系统时间与硬件时间设置.同步 将系统时间设置成2018年7月31日 12:00:00 date -s "07/31/18  12:00:00" hwclock -s 将 ...

随机推荐

  1. golang之常用方法/函数

    1. io.Reader转化为字符串, byte切片 import "bytes" func StreamToByte(stream io.Reader) []byte { buf ...

  2. Linux之EOF

    常见问题: 1.在EOF中存在特殊字符,例如$ 导致后面的无法识别, 因为默认会对变量自动替换 使用引号处理 cat >> a.sh << "EOF" ec ...

  3. Python之错误码设计

    在 web 项目中,我们经常使用自定义状态码来告知请求方请求结果以及请求状态:在 Python 中该如何设计自定义的状态码信息呢? 1)普通类+字典设计状态码 #!/usr/bin/python3 # ...

  4. Codeforces Round 832 (Div2)

    Swap Game Alice 和 Bob 两个人在玩游戏. 有一个长度为 \(n\) 的序列 \(a\),Alice 和 Bob 两人轮流完成一个操作,Alice 先开始. 每个人可以将数列的第一个 ...

  5. 通过加密的方式做身份鉴权—Demo设计

    目录 鉴权方式 账号+密码 账号+短信验证码 第三方渠道鉴权--微信 Reference 本文只是一个Demo设计,仅供学习思路,并不能用于真实的线上业务,因为有很多漏洞. 一般线上应用都需要对用户身 ...

  6. DataGridView频繁更新PLC报警信息数据源

    1.问题描述 当DataGridView频繁更新数据源时,可能会导致界面闪烁.性能下降等问题.这是因为每次更新数据源时,DataGridView都需要重新绘制和绑定数据,这是一个相对耗时的过程. 2. ...

  7. 零基础学习人工智能—Python—Pytorch学习(十二)

    前言 本文介绍使用神经网络进行实战. 使用的代码是<零基础学习人工智能-Python-Pytorch学习(九)>里的代码. 代码实现 mudule定义 首先我们自定义一个module,创建 ...

  8. COSBrowser iOS 版 | 如何不打开 App 查看监控数据?

    您是否有遇到这样的场景?当需要实时查看存储监控数据.查看某个存储桶的对象数量,又或者想了解某一个存储类型文件的下载量在当前与前一天的对比情况,是上涨了还是下降了,这时您是否也在经历频繁的打开关闭 Ap ...

  9. 中电金信:GienTech动态|一波好消息→中标!多领域“开花”

  10. Proxmox VE(虚拟机集群)安装配置

    #Proxmox VE 安装配置 创建kvm模板 有私有云需求, 创建与管理Windows和Linux虚拟机的场景,使用PVE(Proxmox VE)管理很方便. 本人使用PVE管理公司开发测试环境几 ...