ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

Centos 8 搭建时钟服务器

2021-06-10 21:04:22  阅读:217  来源: 互联网

标签:Centos ntp chrony conf NTP 服务器 pool 时钟


Centos 8 搭建时钟服务器

原创 Linux操作系统 作者:strivechao 时间:2020-08-10 14:33:54  940  0

Centos 8 搭建时钟服务器

 

由于CentOS8.0中默认不再支持ntp软件包,时间同步将由chrony来实现。

安装chrony

yum install chrony -y

设置chrony随系统自动启动

systemctl enable chronyd

配置chrony.conf,允许客户端同步

vi /etc/chrony.conf
# 使用 pool.ntp.org 项目中的公共服务器。以server开,理论上想添加多少时间服务器都可以。
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool ().
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

https://www.cnblogs.com/jhxxb/p/11526098.html

https://www.cnblogs.com/yinzhengjie/p/12292549.html

 

 

  1. 选择您设置为 NTP 服务器的主机。
  2. 编辑 /etc/chrony.conf 并确保它具有以下行:
    driftfile /var/lib/chrony/drift
    local stratum 8
    manual
    allow 192.168.165

    允许字段中的地址为允许客户机从其进行连接的网络地址或子网地址。

  3. 在客户机上,编辑  /etc/chrony.conf 并确保它具有以下行:
    server master iburst
    driftfile /var/lib/chrony/drift
    logdir /var/log/chrony
    log measurements statistics tracking
  4. 在每个主机上启动并启用 chronyd:
    systemctl start chronyd 
    systemctl enable chronyd

 

查看日期时间及NTP状态:# timedatectl
查看和配置时区:# timedatectl list-timezones;# timedatectl set-timezone Asia/Shanghai
修改日期时间:# timedatectl set-time "2018-10-21 11:50:00"(可以只修改其中一个)
开启NTP:# timedatectl set-ntp true/flase
查看chrony服务所有conf配置文件分布# rpm -ql chrony |grep conf
检查chrony服务配置文件所在# rpm -qc chrony
查看chrony安装情况# rpm -qi chrony
检查ntp安装情况# yum search ntp |grep ^ntp.x86_64或# yum search ntp(列出所有ntp相关包)



 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/25469263/viewspace-2710480/,如需转载,请注明出处,否则将追究法律责任。

标签:Centos,ntp,chrony,conf,NTP,服务器,pool,时钟
来源: https://www.cnblogs.com/xuanbjut/p/14872764.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有