Linux时间同步服务 - chronyd

简介: Linux时间同步服务 - chronyd

Linux时间同步服务 - chronyd

安装

使用软件包安装工具安装chronyntp

  • Arch Linux系列:
sudo pacman -S ntp chrony
  • Debian系列:
sudo apt install ntp chrony
  • Red Hat系列:
sudo yum install ntp chrony
  • 或者
sudo dnf install ntp chrony

配置

① 在chrony配置文件中,将原授时NTP服务器注释,并填入阿里或腾讯NTP授时服务器网址,示例如下:

### SPECIFY YOUR NTP SERVERS
# Most computers using chrony will send measurement requests to one or
# more 'NTP servers'.  You will probably find that your Internet Service
# Provider or company have one or more NTP servers that you can specify.
# Failing that, there are a lot of public NTP servers.  There is a list
# you can access at http://support.ntp.org/bin/view/Servers/WebHome or
# you can use servers from the pool.ntp.org project.
#! server 0.arch.pool.ntp.org iburst
#! server 1.arch.pool.ntp.org iburst
#! server 3.arch.pool.ntp.org iburst
#pool 2.arch.pool.ntp.org iburst
# The URL of Tencent NTP network time server is as follows:
! server ntp.tencent.com iburst
! server ntp2.tencent.com iburst
! server ntp3.tencent.com iburst
! server ntp4.tencent.com iburst
! server ntp5.tencent.com iburst
# The URL of Ali NTP network time server is as follows:
! server ntp.aliyun.com iburst
! server ntp1.aliyun.com iburst
! server ntp2.aliyun.com iburst
! server ntp3.aliyun.com iburst
! server ntp4.aliyun.com iburst
! server ntp5.aliyun.com iburst
! server ntp6.aliyun.com iburst
! server ntp7.aliyun.com iburst
pool ntp1.tencent.com

注意:

选择其中三、四个即可。

② 输入如下命令,使得防火墙为chronyd服务放行,以便chronyd服务顺利运行:

  • Firewalld设置:
$ firewall-cmd --add-service=ntp --permanent
$ firewall-cmd --reload
  • Ufw设置:
$ sudo ufw allow ntp
$ sudo ufw allow out ntp

管理

使用systemctl命令允许chronyd服务开机自启动、使得chronyd服务启动并查看chronyd服务的运行状态,具体命令如下所示:

# systemctl start chronyd.service    #启动
# systemctl status chronyd.service     #查看
# systemctl enable chronyd.service    #设置开机启动

使用如下命令,查看时间同步源:

$ chronyc sources -v

使用如下命令,查看时间同步源状态:

$ chronyc sourcestats -v

使用如下命令,启用NTP时间同步:

$ timedatectl set-ntp yes

使用如下命令,校准时间服务器:

$ chronyc tracking

注意:

配置完/etc/chrony.conf后,需重启chrony服务,否则可能会不生效。

目录
打赏
0
0
0
0
55
分享
相关文章
|
3月前
|
在Linux、CentOS7中设置shell脚本开机自启动服务
以上就是在CentOS 7中设置shell脚本开机自启动服务的全部步骤。希望这个指南能帮助你更好地管理你的Linux系统。
166 25
|
4月前
|
Linux系统管理:服务器时间与网络时间同步技巧。
以上就是在Linux服务器上设置时间同步的方式。然而,要正确运用这些知识,需要理解其背后的工作原理:服务器根据网络中的其他机器的时间进行校对,逐步地精确自己的系统时间,就像一只犹豫不决的啮齿动物,通过观察其他啮齿动物的行为,逐渐确定自己的行为逻辑,既简单,又有趣。最后希望这个过程既能给你带来乐趣,也能提高你作为系统管理员的专业素养。
579 20
|
4月前
|
Gitea Enterprise 23.4.0 (Linux, macOS, Windows) - 本地部署的企业级 Git 服务
Gitea Enterprise 23.4.0 (Linux, macOS, Windows) - 本地部署的企业级 Git 服务
97 0
Gitea Enterprise 23.4.0 (Linux, macOS, Windows) - 本地部署的企业级 Git 服务
Linux 中停止 Docker 服务报 warning 导致无法彻底停止问题如何解决?
在 Linux 系统中,停止 Docker 服务时遇到警告无法彻底停止的问题,可以通过系统管理工具停止服务、强制终止相关进程、检查系统资源和依赖关系、以及重置 Docker 环境来解决。通过以上步骤,能够有效地排查和解决 Docker 服务停止不彻底的问题,确保系统的稳定运行。
343 19
|
6月前
|
Linux systemd 服务启动失败Main process exited, code=exited, status=203/EXEC
通过以上步骤,可以有效解决 systemd 服务启动失败并报错 `Main process exited, code=exited, status=203/EXEC` 的问题。关键在于仔细检查单元文件配置、验证可执行文件的有效性,并通过日志分析具体错误原因。确保可执行文件路径正确、文件具有执行权限,并且可以独立运行,将有助于快速定位和解决问题。
2894 7
|
11月前
|
在Linux中,怎么把脚本添加到系统服务里,即用 service 来调用?
在Linux中,怎么把脚本添加到系统服务里,即用 service 来调用?
linux系统服务二!
本文详细介绍了Linux系统的启动流程,包括CentOS 7的具体启动步骤,从BIOS自检到加载内核、启动systemd程序等。同时,文章还对比了CentOS 6和CentOS 7的启动流程,分析了启动过程中的耗时情况。接着,文章讲解了Linux的运行级别及其管理命令,systemd的基本概念、优势及常用命令,并提供了自定义systemd启动文件的示例。最后,文章介绍了单用户模式和救援模式的使用方法,包括如何找回忘记的密码和修复启动故障。
127 5
linux系统服务二!
linux系统服务!!!
本文详细介绍了Linux系统(以CentOS7为例)的启动流程,包括BIOS自检、读取MBR信息、加载Grub菜单、加载内核及驱动程序、启动systemd程序加载必要文件等五个主要步骤。同时,文章还对比了CentOS6和CentOS7的启动流程图,并分析了启动流程的耗时。此外,文中还讲解了Linux的运行级别、systemd的基本概念及其优势,以及如何使用systemd管理服务。最后,文章提供了单用户模式和救援模式的实战案例,帮助读者理解如何在系统启动出现问题时进行修复。
129 3
linux系统服务!!!
Linux操作系统的守护进程与服务管理深度剖析####
本文作为一篇技术性文章,旨在深入探讨Linux操作系统中守护进程与服务管理的机制、工具及实践策略。不同于传统的摘要概述,本文将以“守护进程的生命周期”为核心线索,串联起Linux服务管理的各个方面,从守护进程的定义与特性出发,逐步深入到Systemd的工作原理、服务单元文件编写、服务状态管理以及故障排查技巧,为读者呈现一幅Linux服务管理的全景图。 ####
Linux服务如何实现服务器重启后的服务延迟自启动?
【10月更文挑战第25天】Linux服务如何实现服务器重启后的服务延迟自启动?
1028 3
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等

登录插画

登录以查看您的控制台资源

管理云资源
状态一览
快捷访问