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. 解码OutOfMemoryError:PermGen Space

    本文由 ImportNew - Peter Pan 翻译自 javacodegeeks.如需转载本文,请先参见文章末尾处的转载要求. ImportNew注:如果你也对Java技术翻译分享感兴趣,欢迎加 ...

  2. golang之jwt的token登录

    什么是 JSON Web Token? JSON Web Token(JWT)是一个开放标准(RFC 7519),它定义了一种紧凑且自包含的方式,用于在各方之间以 JSON 方式安全地传输信息.由于此 ...

  3. Python 学习记录(2)

    NumPy数组规整 对数组进行各种变化 转换数组形状 import numpy as np a=np.arange(1,6+1) b=np.reshape(a,(2,3)) print(a) prin ...

  4. Python3 print不输出回车符

    Python3 print的函数原型: print(*objects, sep=' ', end='\n', file=sys.stdout, flush=False) objects ---- 输出 ...

  5. 如何给自己的网站添加live2D女仆

    <script type="text/javascript" charset="utf-8"  src="https://files.cnblo ...

  6. PM-软件最难的不是开发程序,而是需求

    最近几个月,关于人工智能的惊人文章在互联网泛滥.这也引发了很多人的担心--软件开发人员可能很快就会失业,被人工智能取代.他们想象所有的企业高管和产品研究人员将绕过大多数或所有的软件开发人员,直接要求人 ...

  7. HttpClientFactory in ASP.NET Core 2.1 Part 3: 对处理器使用对外请求中间件

    HttpClientFactory in ASP.NET Core 2.1 Part 3: 对处理器使用对外请求中间件 原文地址:https://www.stevejgordon.co.uk/http ...

  8. JSchException: Algorithm negotiation fail问题解决之路

    最近一个需求用到了SFTP上传功能,同事之前已经封装好了SFTP工具类,用的是JSch,本着不要重复造轮子的想法,就直接拿来用了.交代下环境,JDK为1.7,JSch版本为0.1.51.自测通过.测试 ...

  9. Netty内存池泄漏问题

    为了提升消息接收和发送性能,Netty针对ByteBuf的申请和释放采用池化技术,通过PooledByteBufAllocator可以创建基于内存池分配的ByteBuf对象,这样就避免了每次消息读写都 ...

  10. Socket、Http、WebSocket?强大的Netty几行语句就帮你实现!

    一.概述 Netty是目前最流行的由JBOSS提供的一个Java开源框架NIO框架,Netty提供异步的.事件驱动的网络应用程序框架和工具,用以快速开发高性能.高可靠性的网络服务器和客户端程序. 相比 ...