温馨提示:这篇文章已超过838天没有更新,请注意相关的内容是否还可用!
步骤1:安装 NTP
安装 NTP:
yum install ntp
步骤2:配置 NTP
编辑 /etc/ntp.conf 文件,并按照以下示例进行配置:
# Use servers from the NTP Pool Project. server 0.centos.pool.ntp.org iburst server 1.centos.pool.ntp.org iburst server 2.centos.pool.ntp.org iburst server 3.centos.pool.ntp.org iburst # By default, exchange time with everybody, but don't allow configuration. restrict -4 default kod notrap nomodify nopeer noquery limited restrict -6 default kod notrap nomodify nopeer noquery limited # Local users may interrogate the ntp server more closely. restrict 127.0.0.1 restrict ::1 # Needed for adding pool entries restrict source notrap nomodify noquery
步骤3:启动 NTP
启动 NTP 服务:
systemctl start ntpd
并使 NTP 服务随系统启动:
systemctl enable ntpd
步骤4:检查 NTP
等待一段时间后,可以使用 ntpq -p 命令检查 NTP 状态:
ntpq -p
如果一切正常,则应该会看到类似以下内容的输出:
remote refid st t when poll reach delay offset jitter ============================================================================== *0.centos.pool. .POOL. 16 p - 64 0 0.000 0.000 0.000 +ntp2.hostings. 172.31.16.58 3 u 18 64 1 0.492 -0.252 0.024 -2.centos.pool. .POOL. 16 p - 64 0 0.000 0.000 0.000 +3.centos.pool. .POOL. 16 p - 64 0 0.000 0.000 0.000
这表示 NTP 服务正在与其他 NTP 服务器进行同步。
希望这可以帮助您成功搭建 NTP 服务。
还没有评论,来说两句吧...