TICK/TIGK運維棧安裝運行 docker-compose【下】

InfluxDBpython

 

構建Dockerfile
vim /opt/influxdb-docker/Dockerfilegit

FROM influxdb
COPY influxdb.conf /etc/influxdb/influxdb.conf
EXPOSE 8086

vim /opt/influxdb-docker/docker-compose.ymlgithub

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

cd /opt/influxdb-docker
docker-compose build
docker-compose up -d
docker-compose down
docker-compose restartsql

測試是否安裝成功docker

接口進行訪問
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 PRIVILEGESvim

若是有問題,docker複製出配置文件查看 docker cp influxdb1:/etc/influxdb/influxdb.conf /optbash

 

 

 

telegrafapp


下載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.shless

構建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;chown 472:472 /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

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 8086

mkdir -p /var/lib/grafana;chown 472:472 /var/lib/grafana

vim /opt/grafana-docker/docker-compose.yml

version: '3.4'
services:
  grafana:
    image: grafana1:latest
    container_name: grafana1
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - 3000:3000
    volumes:
      - /var/lib/grafana:/var/lib/grafana
      - /etc/localtime:/etc/localtime:ro
    restart: unless-stopped

cd /opt/grafana-docker
docker-compose build
docker-compose up -d

進入網站 用戶名密碼都是admin


第一步建立datasource
Name爲telegraf與上面telegraf配置的數據庫名一致
influxdb開啓了auth-enabled = true
須要勾選Basic Auth 數據庫用戶名密碼都是root

後面的dashboard隨意了,記得在sql語句中選擇表和列,部分列能夠按*顯示,不然不會展現數據

相關文章
相關標籤/搜索