Categories: Linux

Linux配置NTP时间同步

如果我们的服务器没有NTP会造成每台服务器时间不一致,这样会造成一个问题,比如我们要查看服务器日志,然后会造成不同服务器日志时间不一样,到时候就比较麻烦了。

由于我们内部没有专门的NTP服务器,所以我们使用公网的NTP服务器。

我们先安装NTP组件

# yum -y install ntp

编辑下NTP配置文件

# vi /etc/ntp.conf

将原来的服务器删除改成下面的服务器,这是我国的NTP服务器地址,访问速度较快
server 192.168.77.249 prefer

server 192.168.77.250 prefer

prefer优先的意思 本地ntp,优先同步

CentOS6后续设置

启动NTP服务

# service ntpd start

设置开机启动

# chkconfig ntpd on

查看ntp状态

# service ntpd status

# /sbin/iptables -I INPUT -p udp --dport 123 -j ACCEPT

# /etc/rc.d/init.d/iptables save

# /etc/init.d/iptables restart

# /etc/init.d/iptables status

 
 

CentOS7后续设置

[root@localhost /]# systemctl start ntpd.service#启动服务

[root@localhost /]# systemctl enable ntpd.service#设置为开机启动

# systemctl status ntpd.service #查看NTP状态

firewall-cmd --zone=public --add-port=123/udp --permanent

firewall-cmd --reload

 
 

设置同步NTP服务器,设置完成后执行下面的命令,让客户端与ntp服务器强制同步

ntpdate -u 192.168.77.250

ntpdate -d 192.168.77.250

王哥哥

Share
Published by
王哥哥

Recent Posts

ESXi精简置备盘空间回收

   家里的nuc上lab环境…

3 月 ago

Dell MD系列存储重置管理密码

正好手里有几台Dell MD3…

3 月 ago

Dell ME4存储管理口无法登录修复

这次碰到一台DELL ME40…

3 月 ago

分享个便宜速度快的云主机

野草云 https://my.…

5 月 ago

众筹微软大佬徐庭老师M365课程

 联系邮箱:gyd1#vip.…

5 月 ago

MySQL EOL和版本推荐

   MySQL 5.7版本已…

6 月 ago