promethues【centos7】时间同步

Promethues和Grafana展示的监控突然消失了,服务器检查发现没什么异常。
当打开promethus网页后,发现有一个错误提示:
image

Warning! Detected 60.44 seconds time difference between your browser and the server. Prometheus relies on accurate time and time drift might cause unexpected query results.
意思应该是时间不同步。
问题找到了,开始解决。

1、进入服务器检查时间

检查时间,发现服务器时间不对,然后同步ntp服务器
显示服务器时间
date
安装ntp服务
yun -y install ntp
与阿里云ntp同步时间
ntpdate ntp.aliyun.com
image

2、更新同步以后还是不正确,如果时区不对

设置时区
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
修改配置文件,添加:
vi /etc/ntp.conf

server ntp.aliyun.com prefer
server cn.ntp.org.cn

手工发起同步:
ntpdate ntp.aliyun.com
启动NTP服务:
service ntpd start
设置开机启动:
chkconfig ntpd on
检查设置:
chkconfig --list ntpd

检查是否同步时间:
date
image

posted @ 2023-03-02 09:53  rootkk  阅读(162)  评论(0编辑  收藏  举报