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

VC 6.0 挂服务 提示503

我们有一台VC 6.0的服务挂…

3 周 ago

零成本grass挖矿教程

最近发现个新币,还没上交易所,…

4 周 ago

Windows Server 2025 的AD架构版本

   Windows 2025…

4 周 ago

【项目】跨数据中心(跨站点)Exchange Server 2013恢复/高可用

今年换到一家乙方公司了,主要工…

1 月 ago

主域挂了怎么办?

假设在极端情况下,没有备份的前…

1 月 ago

为什么在AD管理中只能看到3个操作主机?

我们在日常的Windows域管…

2 月 ago