zoukankan      html  css  js  c++  java
  • 时间同步服务 chromy

    1. chrony 服务器端配置

    假设chrony服务器端192.168.1.1

    $ cat /etc/chrony.conf
    # Use public servers from the pool.ntp.org project.
    server ntp1.aliyun.com iburst
    server ntp2.aliyun.com iburst
    pool pool.ntp.org iburst
    
    # Ignor source level
    stratumweight 0
    
    # 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 five updates
    # if its offset is larger than 1 second.
    makestep 1 5
    
    # Enable kernel synchronization of the real-time clock (RTC).
    rtcsync
    
    # Allow NTP client access from local network.
    allow 0.0.0.0/0
    
    # Serve time even if not synchronized to a time source.
    local stratum 10
    
    # Select which information is logged.
    #log measurements statistics tracking
    
    #
    noclientlog
    

    2. chrony 客户端配置

    $ cat /etc/chrony.conf
    # Use local chrony server.
    server 192.168.1.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 five updates
    # if its offset is larger than 1 second.
    makestep 1 5
    
    # Enable kernel synchronization of the real-time clock (RTC).
    rtcsync
    
    # Select which information is logged.
    #log measurements statistics tracking
    

    3. systemd 服务文件

    /etc/systemd/system/chrony.service

    [Unit]
    Description=chrony
    Documentation=https://github.com/kubeasz/dockerfiles/chrony
    After=docker.service
    Requires=docker.service
    
    [Service]
    User=root
    ExecStart=/opt/kube/bin/docker run 
      --cap-add SYS_TIME 
      --name chrony 
      --network host 
      --volume /etc/chrony.conf:/etc/chrony/chrony.conf 
      --volume /var/lib/chrony:/var/lib/chrony 
      easzlab/chrony:0.1.0
    ExecStartPost=/sbin/iptables -t raw -A PREROUTING -p udp -m udp --dport 123 -j NOTRACK
    ExecStartPost=/sbin/iptables -t raw -A OUTPUT -p udp -m udp --sport 123 -j NOTRACK
    ExecStop=/opt/kube/bin/docker rm -f chrony
    Restart=always
    RestartSec=10
    Delegate=yes
    
    [Install]
    WantedBy=multi-user.target
    

    4. /etc/chrony.conf 释义

    # 同步使用的端口
    acquisitionport 1123
    
    # 存储Server时间的本地目录
    dumpdir /var/run/chrony
    
    # Ignore stratum in source selection.
    stratumweight 0.01
    
    # Record the rate at which the system clock gains/losses time.
    driftfile /var/lib/chrony/drift
    
    # 闰秒配置,17h34m消化1s
    leapsecmode slew
    maxslewrate 1000
    smoothtime 400 0.001 leaponly
    
    # In first three updates step the system clock instead of slew
    # if the adjustment is larger than 10 seconds.
    # makestep 0.1 3
    
    ## Server config
    # Allow NTP client access from local network.
    allow 0.0.0.0/0
    
    # Listen for commands only on localhost.
    bindaddress 0.0.0.0
    port 123
    clientloglimit 1073741824
    #ratelimit interval 1
    #ratelimit burst 16
    # Serve time even if not synchronized to any NTP server.
    local stratum 5 distance 20
    maxdistance 20
    
    ## Command config
    bindcmdaddress 127.0.0.1
    bindcmdaddress /var/run/chrony/chronyd.sock
    cmdallow all
    
    ## Real Time clock(RTC)
    hwclockfile /etc/adjtime
    rtcautotrim 10
    rtcsync
    
    keyfile /etc/chrony.keys
    
    # Specify the key used as password for chronyc.
    commandkey 1
    
    # Generate command key if missing.
    generatecommandkey
    
    ## Log
    # Send a message to syslog if a clock adjustment is larger than 0.5 seconds.
    logchange 0.1
    log measurements statistics tracking
    logdir /var/log/chrony
    
    # Server配置
    #ip address is the stable clock source which customer provided
    bindacqaddress 172.16.79.6
    server ntp.aliyun.com iburst minpoll 4 maxpoll 6 prefer
    server cn.ntp.org.cn iburst minpoll 4 maxpoll 6
    

    5. 其他

    chronyc sources -v   	 # 查看时间同步情况
    chronyc -n tracking -v   # 查看偏移时间
    ntpd -q
    
  • 相关阅读:
    删数问题
    八中公司_二分图带权最大匹配模板题
    完美子图(这道题太难了,得写下来要不回头又忘了)
    最近集训的图论(思路+实现)题目汇总(内容包含tarjan、分层图、拓扑、差分、奇怪的最短路):
    方格取数(简单版)+小烈送菜(不知道哪来的题)-----------奇怪的dp增加了!
    单调队列优化题:最大数(P1198)
    单调队列+线性dp题Watching Fireworks is Fun (CF372C)
    关于看了几道洛谷灰题(暂无评定)的感想
    洛谷的奇妙今日运势
    互不侵犯(洛谷P1896)
  • 原文地址:https://www.cnblogs.com/firewalld/p/14775910.html
Copyright © 2011-2022 走看看