我在 Oracle Linux 8.0 上运行的 Prometheus 容器中遇到时间问题。 我用最少的选项安装了操作系统,之后,我运行了这个命令来调整时间日期时间。
dnf update
dnf -y install chrony
systemctl enable chronyd
vi /etc/chrony.conf
Server <ip ntp server>
chronyc sources
timedatectl set-ntp true
timedatectl set-timezone "America/Sao_Paulo"
timedatectl
在那之后,我用这个命令安装了 docker 和 docker-compose。
--码头工人
dnf install -y dnf-utils
dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
dnf install docker-ce docker-ce-cli containerd.io
systemctl enable docker
systemctl start docker
--Docker-Compose
curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
我通过 docker 运行,使用以下配置与 Prometheus 组成一个容器:
version: '3.0'
networks: monitor-net:
driver: bridge
services: prometheus:
image: prom/prometheus:latest
container_name: prometheus
environment:
- TZ="America/Sao_Paulo"
volumes:
- /opt/prometheus/config:/etc/prometheus
- /opt/prometheus/data:/prometheus
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/etc/prometheus/console_libraries'
- '--web.console.templates=/etc/prometheus/consoles'
- '--storage.tsdb.retention.time=200h'
- '--web.enable-lifecycle'
restart: unless-stopped
ports:
- 9090:9090
networks:
- monitor-net
labels:
org.label-schema.group: "monitoring"
但是两者之间的时间不同,在巴西,UTC 是 -3 就像在主机上一样,但在容器中是 UTC 时间。
[[email protected] mon-central]# date
Fri Mar 31 14:28:11 -03 2023
[[email protected] mon-central]# docker exec -it prometheus /bin/sh
/prometheus $ date
Fri Mar 31 17:28:44 UTC 2023
/prometheus $
我在不同的地方查看了很多文章,包括 Docker 官方网站,并且在 Prometheus 博客中我发现了以下内容:
是否存在某种方法来配置容器以将您的内部时钟与主机时钟同步?有人已经用普罗米修斯遇到这种情况或其他情况并且可以解决吗?
我认为避免这种情况是没有意义的,Prometheus 有一个时间序列数据库,并且像所有数据库一样,信息必须与时间戳一致。 这种情况下所有UTC之外的信息记录都像现实一样大错特错
• 单个 kubernetes 集群中的多个普罗米修斯运算符 [关闭]
• 使用 Prometheus 操作符使用基本身份验证或 TLS 保护 Prometheus 抓取端点
• 升级 Prometheus 到 2.38.0 版本并出现“EOF”错误
• Android Studio 可以使用 OpenJDK 还是需要 Linux 上的 Oracle JDK?
• 通过 ARM oracle 服务器(用于 minecraft 服务器)的 debian x64 代理
• 是否有 Linux 函数来检查是否存在大小写不同的文件名?
• Terraform 中的 Prometheus 配置和部署
• docker 容器中的 Prometheus 显示远程节点即使在节点关闭后也启动
• CBLite Replicator 在清除文档后不重新同步
• 在Grafana中,如何限制用户只能查看属于他们组织的数据?