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

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

#1. 查看当前时间
date

#2. 添加wlnmp源
rpm -ivh http://mirrors.wlnmp.com/centos/wlnmp-release-centos.noarch.rpm

#3. 安装ntp服务
yum install wntp

#4. 时间同步
ntpdate ntp1.aliyun.com

#5. 打开防火墙NTP服务端口,如果没有打开防火墙,就不用操作这一步
#添加NTP服务端口
firewall-cmd --add-service=ntp --permanent
#重新加载NTP服务配置
firewall-cmd --reload

#6. 下载安装chrony
yum install -y chrony

#7. 启动chrony服务
systemctl restart chronyd

#8. 查看chronyd服务状态
systemctl status chronyd

#9.在查看一下同步时间后的时间
date

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

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

第一章 Chrony简介

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

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

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

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

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

chrony is a versatile implementation of the Network Time Protocol (NTP). 
It can synchronise the system clock with NTP servers, reference clocks (e.g. GPS receiver), 
and manual input using wristwatch and keyboard. 
It can also operate as an NTPv4 (RFC 5905) server and peer to provide a time service to other computers in the network.

It is designed to perform well in a wide range of conditions, 
including intermittent network connections, 
heavily congested networks, 
changing temperatures (ordinary computer clocks are sensitive to temperature), 
and systems that do not run continuosly, 
or run on a virtual machine.

Typical accuracy between two machines synchronised over the Internet is within a few milliseconds; 
on a LAN, 
accuracy is typically in tens of microseconds. 
With hardware timestamping, or a hardware reference clock, 
sub-microsecond accuracy may be possible.

Two programs are included in chrony, 
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端口,或直接关闭防火墙。

#把866/tcp换成自己的323/udp
firewall-cmd --zone=public --add-port=866/tcp --permanent

#把866/tcp换成自己的123/udp
firewall-cmd --zone=public --add-port=866/tcp --permanent

# 重新加载
firewall-cmd --reload



#删除866端口,如果不需要删除该端口就不需要操作
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设置开机启动

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

renkai721

谢谢您的打赏!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值