Linux NTP 同步时间

NTP 同步时间

安装

NTP server:

yum install -y ntp

NTP client:

yum install -y ntpdate

启动

# 启动服务
systemctl start ntpd.service

# 查看 123 端口是否开启
netstat -anptu | grep 123

# 设置开机自启
systemctl enable ntpd.service

手动同步

在未启动 NTP 服务时,可以通过

ntpdate 0.rhel.pool.ntp.org

手动同步时间

如果 NTP 服务仍在运行,就会报错:the NTP socket is in use, exiting,需要将 NTP 服务关闭后再进行手动同步

# 关闭 NTP 服务
systemctl stop ntpd.service

配置

配置文件: /etc/ntp.conf

常用 NTP 服务器

中国:

server 0.cn.pool.ntp.org
server 1.cn.pool.ntp.org
server 2.cn.pool.ntp.org
server 3.cn.pool.ntp.org

posted on 2022-01-18 14:23  doubtful  阅读(111)  评论(0编辑  收藏  举报

导航