mkdir -pv /apps/grafana/{conf,data}
配置 data 目录权限:
chmod -R 777 /apps/grafana/data/
vim /apps/grafana/docker-compose.yml
version: '3'
services:
grafana:
image: grafana/grafana:9.1.6
container_name: prometheus-grafana
restart: always
privileged: true
ports:
- 13000:3000
volumes:
- /etc/localtime:/etc/localtime:ro
- /apps/grafana/conf/grafana.ini:/etc/grafana/grafana.ini
- /apps/grafana/data:/var/lib/grafana
networks:
default:
external:
name: prometheus
vim /apps/grafana/conf/grafana.ini
grafana.ini 文件模板:https://github.com/grafana/grafana/blob/main/conf/defaults.ini
grafana.ini 文件说明:https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana
4. 创建 docker 网段 prometheus
检查是否已有 prometheus 网段:
docker network list
没有则创建:
docker network create prometheus --subnet 10.21.22.0/24
cd /apps/grafana
docker-compose up -d
cd /apps/grafana
docker-compose ps
docker-compose logs -f
admin
,默认密码:admin
grafana-cli admin reset-admin-password 新密码