在网上查了很多,全是标题党,说一堆,问题没解决,我裂开~~~~
废话不多说,直接看问题(如图): 大致意思就是浏览器和服务器之间存在时间差,Prometheus依赖精确时间,时间差会导致查询到的数据不准确。
解决方案:
# 1、先看看Prometheus server端的时间
[root@cluster-node-1 prometheus]# date
Thu Jan 28 02:13:18 EST 2021
# 2、再看看你浏览器(电脑)时间,如下图:
瞧见了吗?差了这么多,不警告才有怪~~~
# 3、确保Prometheus server端能通网
ping www.baidu.com
[root@cluster-node-1 ~]# ping www.baidu.com
PING www.a.shifen.com (220.181.38.149) 56(84) bytes of data.
64 bytes from 220.181.38.149 (220.181.38.149): icmp_seq=1 ttl=50 time=27.0 ms
64 bytes from 220.181.38.149 (220.181.38.149): icmp_seq=2 ttl=50 time=27.7 ms
# 4、安装时间同步
yum -y install ntp
# 5、将时间和阿里云服务同步
ntpdate -u time1.aliyun.com
# 6、到浏览器刷新页面就好了
这里也不一定非得同步到阿里云,你可以找一台已经时间同步好的服务,然后将Prometheus server端和它同步就好了
错误总结:
[root@cluster-node-4 ~]# ping www.baidu.com
ping: www.baidu.com: Name or service not known
# 这个错误是没有配置DNS服务,无法解析www.baidu.com
# 解决方法(配置谷歌DNS):
echo "nameserver 114.114.114.114" >> /etc/resolv.conf
echo "nameserver 8.8.8.8" >> /etc/resolv.conf
[root@cluster-node-1 prometheus]# systemctl restart network
[root@cluster-node-1 prometheus]# ntpdate -u 192.168.XXX.XXX
28 Jan 02:21:50 ntpdate[31891]: no server suitable for synchronization found
#这个错误是你同步的服务器没装时间同步ntp服务或者就是没起来
# 解决方法 :
1、先看看有没有ntp服务
[root@cluster-node-1 ~]# ps -ef | grep ntpd
ntp 107975 1 0 10:23 ? 00:00:00 /usr/sbin/ntpd -u ntp:ntp -p /var/run/ntpd.pid -g
root 118567 107884 0 11:08 pts/1 00:00:00 grep --color=auto ntpd
2、有的话就重启一下
[root@cluster-node-1 ~]# systemctl restart ntpd
3、没有就装一个再重启一下
[root@cluster-node-1 ~]# yum -y install ntp
[root@cluster-node-1 ~]# systemctl restart ntpd
说给自己的话:学东西不能仅依靠度娘,知其然,知其所以然才能更好的进步~