当前位置: 首页 > article >正文

centos 9 时间同步服务

        在 CentOS 9 中,默认的时间同步服务是 chrony,而不是传统的 ntpd。 因此,建议使用 chrony 来配置和管理时间同步。 以下是使用 chrony 配置 NTP 服务的步骤:

1. 安装 chrony

首先,确保系统已安装 chrony。 在 CentOS 9 中,chrony 通常已预安装。 如果未安装,可以使用以下命令进行安装:

sudo dnf install -y chrony

2. 启动并启用 chronyd 服务

安装完成后,启动 chronyd 服务,并设置为开机自启:

sudo systemctl enable --now chronyd

3. 配置 NTP 服务器

编辑 /etc/chrony.conf 配置文件,添加或修改 NTP 服务器地址。 例如,使用阿里云的 NTP 服务器:

sudo vi /etc/chrony.conf

在文件中找到以下行:

ini

# Use public servers from the pool.ntp.org project.

# Please consider joining the pool (https://www.pool.ntp.org/join.html).

#pool 2.centos.pool.ntp.org iburst

#pool 2.centos.pool.ntp.org iburst

#pool 2.centos.pool.ntp.org iburst

#pool 2.centos.pool.ntp.org iburst

将其替换为:

ini

# Use public servers from the pool.ntp.org project.

# Please consider joining the pool (https://www.pool.ntp.org/join.html).

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

保存并退出编辑器。

4. 重启 chronyd 服务

修改配置后,重启 chronyd 服务以使更改生效:

sudo systemctl restart chronyd

5. 验证时间同步状态

使用以下命令检查时间同步状态:

chronyc tracking

如果输出中显示 System clock synchronized: yes,则表示时间同步成功。

此外,您还可以使用以下命令查看 NTP 服务器的同步状态:

chronyc sources

如果输出中有 ^* 标记的服务器,表示该服务器正在被使用进行时间同步。

6. 设置时区

如果需要设置时区,可以使用 timedatectl 命令:

sudo timedatectl set-timezone Asia/Shanghai

请根据您的实际时区进行调整。

通过以上步骤,您可以在 CentOS 9 上成功配置 NTP 服务,确保系统时间的准确性。


http://www.kler.cn/a/559284.html

相关文章:

  • ‌挖数据平台对接DeepSeek推出一键云端部署功能:API接口驱动金融、汽车等行业智能化升级
  • WinSCP 连接到 Ubuntu 虚拟机
  • 【鸿蒙开发】HarmonyOS Arkts怎么拿到接口返回的Json数据,console.log显示不全 超长的解决方案
  • 如何使用SSH连接设备?很简单!
  • 【QT】QtBluetooth 低功耗蓝牙BLE 笔记
  • 【Python爬虫(23)】探秘Python爬虫数据存储:MongoDB实战指南
  • 蜡烛CE认证标准GPSD指令下的燃烧测试防火安全规范及产品标签讲解
  • Docker教程(喂饭级!)
  • php session数据存储位置选择
  • LeetCode 热题 100 206. 反转链表
  • 登录功能的实现
  • L2-4 寻宝图
  • 【电机控制器】ESP32-C3语言模型——通义千问
  • 华为 网络安全 认证
  • 22.回溯算法4
  • 【YOLOv11改进- 主干网络】YOLOv11+RepViT: 从ViT的角度重新审视Mobile的CNN助力YOLOv11有效涨点;
  • discuz3.5 回复 浮动窗口无法弹出
  • 在运维工作中,硬盘满了,新买了一块,如何扩容?
  • k2路由器登录校园网
  • ROS2下编写package利用orbbec相机进行yolov8实时目标检测