最近在做一个项目,发现本地测试数据的之间一直是正确的,但是线上的测试数据时间总是出问题。排除代码问题,那么可能是服务器时间不准确
date
查看时间后发现果然时间有问题
yum install ntp #安装ntpdate
ntpdate cn.pool.ntp.org
在运行上述指令的过程中,发现总是有下述错误
[root@xxx]# ntpdate cn.pool.ntp.org
23 Jul 08:30:52 ntpdate[1548]: sendto(time6.aliyun.com): Operation not permitted
23 Jul 08:30:52 ntpdate[1548]: sendto(ntp-sz.chl.la): Operation not permitted
23 Jul 08:30:52 ntpdate[1548]: sendto(dns1.synet.edu.cn): Operation not permitted
23 Jul 08:30:53 ntpdate[1548]: sendto(time6.aliyun.com): Operation not permitted
23 Jul 08:30:53 ntpdate[1548]: sendto(ntp-sz.chl.la): Operation not permitted
23 Jul 08:30:53 ntpdate[1548]: sendto(dns1.synet.edu.cn): Operation not permitted
23 Jul 08:30:54 ntpdate[1548]: sendto(time6.aliyun.com): Operation not permitted
23 Jul 08:30:54 ntpdate[1548]: sendto(ntp-sz.chl.la): Operation not permitted
23 Jul 08:30:54 ntpdate[1548]: sendto(dns1.synet.edu.cn): Operation not permitted
23 Jul 08:30:55 ntpdate[1548]: sendto(time6.aliyun.com): Operation not permitted
23 Jul 08:30:55 ntpdate[1548]: sendto(ntp-sz.chl.la): Operation not permitted
23 Jul 08:30:55 ntpdate[1548]: sendto(dns1.synet.edu.cn): Operation not permitted
23 Jul 08:30:56 ntpdate[1548]: no server suitable for synchronization found
一番折腾后,发现是防火墙问题
service iptables stop # 关闭防火墙
ntpdate cn.pool.ntp.org # 同步时间
service iptables start # 开启防火墙