编辑
2024-04-19
运维
00
请注意,本文编写于 153 天前,最后修改于 153 天前,其中某些信息可能已经过时。

NTP服务器是用于局域网服务器时间同步使用的,可以保证局域网所有的服务器与时间服务器的时间保持一致。

服务端配置:

在服务上安装NTP服务: yum install ntp ntpdate -y

修改配置文件:vi /etc/ntp.conf

配置文件内容:

driftfile /var/lib/ntp/drift restrict default kod nomodify notrap nopeer noquery restrict -6 default kod nomodify notrap nopeer noquery restrict 127.0.0.1 restrict -6 ::1 server x.x.x.x fudge x.x.x.x stratum 10 includefile /etc/ntp/crypto/pw keys /etc/ntp/keys

重启服务:/etc/init.d/ntpd restart

配置防火墙:vi /etc/sysconfig/iptables

-A INPUT -m state --state NEW -m tcp -p udp --dport 123 -j ACCEPT

查看状态:ntpq -p

官方时间服务器:ntpdate pool.ntp.org

客户端配置:

将客户端指向服务器:ntpdate x.x.x.x

同步出现以下提示:the NTP socket is in use, exiting

将ntpd服务停止,在执行同步命令,执行完成在启动ntpd服务

/etc/init.d/ntpd stop

ntpdate pool.ntp.org

/etc/init.d/ntpd start

配置同步计划任务

crontab -e

分 时 日 月 星期 /usr/sbin/ntpdate ntp-server x.x.x.x >>/usr/local/logs/crontab/ntpdate.log

如果对你有用的话,可以打赏哦
打赏
ali pay
wechat pay

本文作者:Gu

本文链接:

版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!