🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
## 1. 安装ntp 在线安装:`yum install ntp -y` 离线安装: 根据实际环境下载(按以下顺序安装rpm) `autogen-libopts-5.18-5.el7.x86_64.rpm` `ntpdate-4.2.6p5-29.el7.centos.2.x86_64.rpm` `ntp-4.2.6p5-29.el7.centos.2.x86_64.rpm` ## 2. ntp服务端配置 ``` restrict 127.0.0.1  restrict ::1 # Hosts on local network are less restricted. #restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap restrict 192.168.0.0 mask 255.255.254.0 nomodify notrap // 根据实际情况修改 # Use public servers from the pool.ntp.org project. # Please consider joining the pool (http://www.pool.ntp.org/join.html). #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 server 0.cn.pool.ntp.org server 1.cn.pool.ntp.org server 2.cn.pool.ntp.org server 3.cn.pool.ntp.org restrict 0.cn.pool.ntp.org nomodify notrap noquery restrict 1.cn.pool.ntp.org nomodify notrap noquery restrict 2.cn.pool.ntp.org nomodify notrap noquery restrict 3.cn.pool.ntp.org nomodify notrap noquery server 127.0.0.1 # local clock fudge 127.0.0.1 stratum 10 #broadcast 192.168.1.255 autokey    # broadcast server ``` ## 3. ntp客户端配置 ``` #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 server 192.168.0.92 restrict 192.168.0.92 nomodify notrap noquery server 127.0.0.1 # local clock fudge 127.0.0.1 stratum 10 #broadcast 192.168.1.255 autokey    # broadcast server ``` ## 4.补充 ``` systemctl enable ntpd // 设置开机自启动 systemctl start ntpd // 启动服务 ntpq -p // 查看网络中的NTP服务器 ntpstat // 查看时间同步状态,需要等几分钟才能看到同步信息。 // 需要将所有host设置在同一时区 // inappropriate address 127.0.0.1 for the fudge command, line ignored // 将/etc/ntp.conf里的 fudge 改为 Fudge ```