• ntp和chrony


    ntp和chrony

    chrony 简介

    chrony 是 RedHat 开发的,它是网络时间协议(NTP)的另一种实现;
    RHEL/CentOS 7.x 的默认时间同步工具,在 CentOS 6.8之后也添加上了这个工具;
    chrony 可以同时做为 ntp 服务的客户端和服务端;安装完后有两个程序 chronyd、chronyc:
    chronyd 是一个 daemon 守护进程,chronyc 是用来监控 chronyd 性能和配置参数的命令行工具。

    ntp pool

    pool.ntp.org

    ntp 配置文件

    /etc/ntp.conf
    
    复制driftfile  /var/lib/ntp/drift
    pidfile    /var/run/ntpd.pid
    logfile    /var/log/ntp.log
    
    # Access Control Support
    restrict    default kod nomodify notrap nopeer noquery
    restrict -6 default kod nomodify notrap nopeer noquery
    restrict 127.0.0.1
    restrict 192.168.0.0 mask 255.255.0.0 nomodify notrap nopeer noquery
    restrict 172.16.0.0 mask 255.240.0.0 nomodify notrap nopeer noquery
    restrict 100.64.0.0 mask 255.192.0.0 nomodify notrap nopeer noquery
    restrict 10.0.0.0 mask 255.0.0.0 nomodify notrap nopeer noquery
    
    
    # local clock
    server 127.127.1.0
    fudge  127.127.1.0 stratum 10

    chrony 配置文件

    /etc/chrony.conf
    
    复制# 时钟服务器地址
    server ntp1.aliyun.com
    
    # 指定包含 NTP 身份验证密钥的文件。
    local stratum 8
    
    # 指令设置当chronyd从可用源中选择同步源时,每个层应该添加多少距离到同步距离。
    # 默认情况下,CentOS中设置为0,让chronyd在选择源时忽略源的层级
    stratumweight 0
    
    # chronyd程序的主要行为之一,就是根据实际时间计算出计算机增减时间的比率,将它记录到一个文件中是最合理的,它会在重启后为系统时钟作出补偿。
    # 甚至可能的话,会从时钟服务器获得较好的估值。
    driftfile /var/lib/chrony/drift
    
    # rtcsync指令将启用一个内核模式,在该模式中,系统时间每11分钟会拷贝到实时时钟(RTC)。
    rtcsync
    
    # 如果系统时钟的偏移量大于10秒,则允许系统时钟在前三次更新中步进。
    makestep 10 3
    
    # allow / deny - 这里你可以指定一台主机、子网,或者网络以允许或拒绝NTP连接到扮演时钟服务器的机器。
    allow all
    
    # 指定包含 NTP 身份验证密钥的文件。
    keyfile /etc/chrony.keys
    
    # noclientlog
    
    logchange 0.5
    
    logdir /var/log/chrony
    log measurements statistics tracking

    chronyc 命令行工具

    复制# 检查NTP访问是否对特定主机可用
    chronyc accheck
    
    # 查看 ntp_servers
    chronyc sources
    
    # 查看 ntp_servers 状态
    chronyc sourcestats
    
    # 查看 ntp_servers 是否在线
    chronyc activity
    
    # 查看 ntp 详细信息
    chronyc tracking
    
    # 报告已访问到服务器的客户端
    chronyc clients: 

    修改时区

    复制# 查看日期时间、时区及 NTP 状态
    timedatectl
    
    # 查看时区列表
    timedatectl list-timezones
    timedatectl list-timezones |  grep  -E "Asia/Shanghai"
    
    # 修改时区
    timedatectl set-timezone Asia/Shanghai
    
    # 修改日期时间(可以只修改其中一个)
    timedatectl set-time "2020-04-11 16:51:10"
    
    # 开启 NTP
    timedatectl set-ntp true/flase
    来自:https://www.cnblogs.com/hiyang/p/12682234.html#chrony-%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6
     
  • 相关阅读:
    第一个SWT程序
    稀疏数组
    算法与数据结构
    《Java核心技术》学习笔记 第1-3章
    算术运算符
    5.11 rw zip file
    5.10 gob序列化
    5.9 piping between writer and reader
    5.7 io.MultiWriter(buf, f)
    5.7 读写 二进制数据
  • 原文地址:https://www.cnblogs.com/zy09/p/15814642.html
Copyright © 2020-2023  润新知