闪闪大数据之路

Kratos
专注于用户阅读体验的响应式博客主题
  1. 首页
  2. 运维篇
  3. 正文

CentOS 时间同步

2023年 5月 1日 42点热度 0人点赞 0条评论

要在 CentOS 中进行时间同步,可以按照以下步骤进行:

  1. 安装 NTP 客户端
    在终端中输入以下命令以安装 NTP 客户端:

    sudo yum install ntp
  2. 配置 NTP 客户端
    打开 NTP 配置文件 /etc/ntp.conf 并编辑为以下内容:

    # 使用国家授时中心提供的服务器作为参考时间源
    server ntp1.aliyun.com iburst
    server ntp2.aliyun.com iburst
    server ntp3.aliyun.com iburst
    # 允许本地时钟与 NTP 服务器进行校准
    restrict default nomodify notrap nopeer noquery
    restrict 127.0.0.1

    这里使用了阿里云提供的 NTP 服务器,你也可以使用其他可用的 NTP 服务器。

  3. 启动 NTP 服务
    在终端中输入以下命令以启动 NTP 服务:

    sudo systemctl start ntpd
  4. 设置 NTP 服务开机自启动
    在终端中输入以下命令以设置 NTP 服务开机自启动:

    sudo systemctl enable ntpd

    这样 NTP 服务就会在系统启动时自动启动。

检查时间同步状态
在终端中输入以下命令以检查时间同步状态:

ntpq -p

如果输出中包含类似以下内容的内容,表示时间同步已经成功:

remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*192.168.1.1     210.72.145.44    2 u  123 1024  377    0.387    0.043   0.135
+time.nist.gov   .ACTS.           1 u  232 1024  377   48.010    1.774  14.163

完成上述步骤后,CentOS 系统的时间就会自动与 NTP 服务器进行同步,保证系统时间的准确性。

标签: 暂无
最后更新:2023年 5月 1日

OXIDA

这个人很懒,什么都没留下

点赞
< 上一篇

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

归档

  • 2023年5月
  • 2023年4月

分类

  • 未分类
  • 运维篇

COPYRIGHT © 2023 闪闪大数据之路. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang