• centos8同步时间安装时间校准服务


    多余的话都写在教程的后面,直接进入下面的操作命令。下面所有的操作都必须使用root账户来操作。切记。

    1. #1. 查看当前时间
    2. date
    3. #2. 添加wlnmp源
    4. rpm -ivh http://mirrors.wlnmp.com/centos/wlnmp-release-centos.noarch.rpm
    5. #3. 安装ntp服务
    6. yum install wntp
    7. #4. 时间同步
    8. ntpdate ntp1.aliyun.com
    9. #5. 打开防火墙NTP服务端口,如果没有打开防火墙,就不用操作这一步
    10. #添加NTP服务端口
    11. firewall-cmd --add-service=ntp --permanent
    12. #重新加载NTP服务配置
    13. firewall-cmd --reload
    14. #6. 下载安装chrony
    15. yum install -y chrony
    16. #7. 启动chrony服务
    17. systemctl restart chronyd
    18. #8. 查看chronyd服务状态
    19. systemctl status chronyd
    20. #9.在查看一下同步时间后的时间
    21. date

     ------------------------------------------------华丽的分割线-------------------------------------------

    经过上面的操作,相信大家的时间一定都设置好了吧。开始唠嗑……

    第一章 Chrony简介

    Chrony是网络时间协议 (NTP) 的通用实现。它可以将系统时钟与 NTP 服务器、参考时钟(例如 GPS 接收器)同步,以及使用手表和键盘手动输入。它还可以作为 NTPv4 (RFC 5905) 服务器和对等点运行,为网络中的其他计算机提供时间服务。

    它旨在在各种条件下都表现良好,包括间歇性网络连接、严重拥塞的网络、不断变化的温度(普通计算机时钟对温度敏感)以及不能连续运行或在虚拟机上运行的系统。

    通过 Internet 同步的两台机器之间的典型精度在几毫秒内;在 LAN 上,精度通常以几十微秒为单位。使用硬件时间戳或硬件参考时钟,亚微秒精度可能是可能的。

    中包含两个程序chrony,chronyd一个是可以在引导时启动的守护程序,另一个chronyc是一个命令行界面程序,可用于监控chronyd的性能并在运行时更改各种操作参数。

    上面的翻译来自GOOGLE。原文如下

    1. chrony is a versatile implementation of the Network Time Protocol (NTP).
    2. It can synchronise the system clock with NTP servers, reference clocks (e.g. GPS receiver),
    3. and manual input using wristwatch and keyboard.
    4. It can also operate as an NTPv4 (RFC 5905) server and peer to provide a time service to other computers in the network.
    5. It is designed to perform well in a wide range of conditions,
    6. including intermittent network connections,
    7. heavily congested networks,
    8. changing temperatures (ordinary computer clocks are sensitive to temperature),
    9. and systems that do not run continuosly,
    10. or run on a virtual machine.
    11. Typical accuracy between two machines synchronised over the Internet is within a few milliseconds;
    12. on a LAN,
    13. accuracy is typically in tens of microseconds.
    14. With hardware timestamping, or a hardware reference clock,
    15. sub-microsecond accuracy may be possible.
    16. Two programs are included in chrony,
    17. chronyd is a daemon that can be started at boot time and chronyc is a command-line interface program which can be used to monitor chronyd’s performance and to change various operating parameters whilst it is running.

    第二章 chrony 的优势

    chrony的优势是更快的同步,从而最大程度减少了时间和频率误差,对于并非全天 24 小时运行的虚拟计算机而言非常有用,能够更好地响应时钟频率的快速变化,对于具备不稳定时钟的虚拟机或导致时钟频率发生变化的节能技术而言非常有用。
    在初始同步后,它不会停止时钟,以防对需要系统时间保持单调的应用程序造成影响
    在应对临时非对称延迟时(例如,在大规模下载造成链接饱和时)提供了更好的稳定性
    无需对服务器进行定期轮询,因此具备间歇性网络连接的系统仍然可以快速同步时钟。

    chrony官网icon-default.png?t=M7J4https://chrony.tuxfamily.orgchrony官方文档icon-default.png?t=M7J4https://chrony.tuxfamily.org/documentation.html

    第三章 防火墙配置

    开放 323/udp,123/udp端口,或直接关闭防火墙。

    1. #把866/tcp换成自己的323/udp
    2. firewall-cmd --zone=public --add-port=866/tcp --permanent
    3. #把866/tcp换成自己的123/udp
    4. firewall-cmd --zone=public --add-port=866/tcp --permanent
    5. # 重新加载
    6. firewall-cmd --reload
    7. #删除866端口,如果不需要删除该端口就不需要操作
    8. firewall-cmd --zone=public --remove-port=866/tcp --permanent

     

    第四章 chrony 的命令

    输入chronyc回车就进入交互式模式,进入交互式模式可以使用help命令查看帮助列表。常用指令说明如下:

    accheck检查NTP访问是否对特定主机可用
    activity该命令会显示有多少NTP源在线/离线
    add server手动添加一台新的NTP服务器。
    clients在客户端报告已访问到服务器
    delete手动移除NTP服务器或对等服务器
    settime手动设置守护进程时间
    tracking显示系统时间信息
    说明:chronyd和chronyc的详细使用方法可以使用命令# man chronyd和# man chronyc查看

     

    第五章 chrony 的服务管理

    systemctl start chronyd.service启动
    systemctl status chronyd.service查看当前状态
    systemctl restart chronyd.service重启
    systemctl stop chronyd.service停止
    systemctl enable chronyd.service设置开机启动

  • 相关阅读:
    Acwing 835. Trie字符串统计
    Day9力扣打卡
    Kafka收发消息核心参数详解
    Java调用Web Service接口
    Caller 服务调用 - Dapr
    11---OpenCV:图像进阶操作之①轮廓②凸包操作
    没有预热,不叫高并发「限流算法第三把法器:令牌桶算法」
    web前端——javaScript
    324. 摆动排序 II : 不简单的构造题
    learn编码器
  • 原文地址:https://blog.csdn.net/renkai721/article/details/126664531