InfluxDB
构建Dockerfile
vim /opt/influxdb-docker/Dockerfile
FROM influxdb COPY influxdb.conf /etc/influxdb/influxdb.conf EXPOSE 8086
vim /opt/influxdb-docker/docker-compose.yml
version: '3.4' services: influxdb: image: influxdb1:latest container_name: influxdb1 build: context: . dockerfile: Dockerfile volumes: - ./influxdb.conf:/etc/influxdb/influxdb.conf - /var/lib/influxdb:/var/lib/influxdb - /etc/localtime:/etc/localtime:ro ports: - 8086:8086 restart: unless-stopped
mkdir -p /var/lib/influxdb;chmod -R 777 /var/lib/influxdb
mkdir -p /var/log/influxdb;chmod -R 777 /var/log/influxdb
cd /opt/influxdb-docker
docker-compose build
docker-compose up -d
docker-compose down
docker-compose restart
测试是否安装成功
接口进行访问
curl -G http://localhost:8086/query --data-urlencode "q=show databases"
docker exec -it influxdb1 /bin/bash
influx
show users
默认没有用户名密码,需创建管理员
CREATE USER "root" WITH PASSWORD 'root' WITH ALL PRIVILEGES
如果有问题,docker复制出配置文件查看 docker cp influxdb1:/etc/influxdb/influxdb.conf /opt
telegraf
下载wait-for-it.sh用于依赖influxdb的docker-compose
https://github.com/vishnubob/wait-for-it
放到/opt/telegraf-docker/ 里
https://github.com/vishnubob/wait-for-it/blob/master/wait-for-it.sh复制脚本
填入vim /opt/telegraf-docker/wait-for-it.sh
构建Dockerfile
vim /opt/telegraf-docker/Dockerfile
FROM telegraf COPY telegraf.conf /etc/telegraf/telegraf.conf COPY ./wait-for-it.sh /opt/wait-for-it.sh RUN chmod 777 /opt/wait-for-it.sh
vim /opt/telegraf-docker/docker-compose.yml
version: '3.4' services: telegraf: image: telegraf1:latest container_name: telegraf1 build: context: . dockerfile: Dockerfile #command: ["/opt/wait-for-it.sh", "192.168.1.102:8086", "--", "python", "app.py"] volumes: - ./telegraf.conf:/etc/telegraf/telegraf.conf - ./wait-for-it.sh:/etc/wait-for-it.sh - /etc/localtime:/etc/localtime:ro restart: always
cd /opt/telegraf-docker
docker-compose build
docker-compose up -d
docker-compose up -d --build
查看telegraf1容器近30分钟的日志
docker logs --since 30m telegraf1
kapacitor
构建Dockerfile
vim /opt/kapacitor-docker/Dockerfile
FROM kapacitor COPY telegraf.conf /etc/kapacitor/kapacitor.conf COPY ./wait-for-it.sh /opt/wait-for-it.sh RUN chmod 777 /opt/wait-for-it.sh
vim /opt/kapacitor-docker/docker-compose.yml
version: '3.4' services: telegraf: image: kapacitor1:latest container_name: kapacitor1 build: context: . dockerfile: Dockerfile #command: ["/opt/wait-for-it.sh", "192.168.1.102:8086", "--", "python", "app.py"] volumes: - ./kapacitor.conf:/etc/kapacitor/kapacitor.conf - ./wait-for-it.sh:/etc/wait-for-it.sh - /etc/localtime:/etc/localtime:ro restart: always
cd /opt/tkapacitor-docker
docker-compose build
docker-compose up -d
docker-compose up -d --build
查看kapacitor1容器近30分钟的日志
docker logs --since 30m kapacitor1
Chronograf
构建Dockerfile
mkdir /opt/chronograf-docker
vim /opt/chronograf-docker/Dockerfile
FROM chronograf EXPOSE 8888
mkdir -p /var/lib/chronograf;chmod -R 777 /var/lib/chronograf
vim /opt/chronograf-docker/docker-compose.yml
version: '3.4' services: grafana: image: chronograf1:latest container_name: chronograf1 build: context: . dockerfile: Dockerfile ports: - 8085:8888 volumes: - /var/lib/chronograf:/var/lib/chronograf - /etc/localtime:/etc/localtime:ro restart: unless-stopped
mkdir -p /var/lib/chronograf;chmod -R 777 /var/lib/chronograf
mkdir -p /var/log/chronograf;chmod -R 777 /var/log/chronograf
cd /opt/chronograf-docker
docker-compose build
docker-compose up -d
Grafana
构建Dockerfile
mkdir /opt/grafana-docker
vim /opt/grafana-docker/Dockerfile
FROM grafana/grafana EXPOSE 3000
mkdir -p /var/lib/grafana;chmod -R 777 /var/lib/grafana
vim /opt/grafana-docker/docker-compose.yml
version: '3.7' services: grafana: image: v-grafana container_name: grafana build: context: . dockerfile: Dockerfile ports: - 3000:3000 environment: - GF_SECURITY_ADMIN_USER=${ADMIN_USER:-admin} - GF_SECURITY_ADMIN_PASSWORD=${ADMIN_PASSWORD:-admin} - GF_USERS_ALLOW_SIGN_UP=true volumes: - /var/lib/grafana:/var/lib/grafana - /var/log/grafana:/var/log/grafana - ./etc/grafana/provisioning:/etc/grafana/provisioning - /etc/localtime:/etc/localtime:ro restart: unless-stopped
mkdir -p /var/lib/grafana;chmod -R 777 /var/lib/grafana
mkdir -p /var/log/grafana;chmod -R 777 /var/log/grafana
mkdir -p /opt/grafana/etc/grafana/provisioning/datasources;
mkdir -p /opt/grafana/etc/grafana/provisioning/notifiers;
mkdir -p /opt/grafana/etc/grafana/provisioning/dashboards;
chmod -R 777 /opt/grafana/etc/grafana/provisioning
/var/lib/grafana 为数据库所在目录
生成启动
cd /opt/grafana-docker/
docker-compose build
docker-compose up -d --force-recreate
docker-compose down
docker-compose restart
查看进程
netstat -anltp|grep 3000
查看日志
docker logs --tail="500" grafana
docker logs -f grafana
进入容器
docker exec -it grafana /bin/bash
进入网站 用户名密码都是admin
配置详解:https://blog.csdn.net/wzygis/article/details/52727067
第一步创建datasource
Name为telegraf与上面telegraf配置的数据库名一致
influxdb开启了auth-enabled = true
需要勾选Basic Auth 数据库用户名密码都是root
后面的dashboard随意了,记得在sql语句中选择表和列,部分列可以按*显示,否则不会展示数据