docker容器实战-0925

普罗米修斯实战

普罗米修斯的配置文件

global:
  scrape_interval:     15s
  evaluation_interval: 15s

scrape_configs:
  - job_name: 'prometheus'
    static_configs:
    - targets: ['localhost:9090']
  - job_name: 'node_exporter'
    static_configs:
    - targets: ['ke.hogwarts.ceshiren.com:5005']
  - job_name: 'mysql'
    static_configs:
    - targets: ['ke.hogwarts.ceshiren.com:5009']
  - job_name: 'cadvisor'
    static_configs:
    - targets: ['ke.hogwarts.ceshiren.com:8091']
  - job_name: 'pushgateway'
    static_configs:
    - targets: ['ke.hogwarts.ceshiren.com:9091']
      labels:
        instance: pushgateway

普罗米修斯的启动命令

docker run --name=prometheus  -d -p 5004:9090 -v $(pwd)/prometheus.yml:/etc/prometheus/prometheus.yml  prom/prometheus

grafana启动命令

docker run --name grafana -d -p 5007:3000 grafana/grafana

node-exporter启动命令

nohup ./node_exporter/node_exporter --web.listen-address=":5005"   >> node_exporter.log 2>&1 &

mysql exporter

docker run -d --name mysql-exporter -p 5009:9104 -e DATA_SOURCE_NAME="root:1qaz9ol.@(47.93.32.161:5008)/mysql" prom/mysqld-exporter

普罗米修斯的文档

docker-compose模版

version: '2'

services:
  mariadb:
    image: 'bitnami/mariadb:latest'
    environment:
      - MARIADB_USER=bn_testlink
      - MARIADB_DATABASE=bitnami_testlink
      - ALLOW_EMPTY_PASSWORD=yes
  testlink:
    image: 'bitnami/testlink:latest'
    environment:
      - MARIADB_HOST=mariadb
      - MARIADB_PORT_NUMBER=3306
      - TESTLINK_DATABASE_USER=bn_testlink
      - TESTLINK_DATABASE_NAME=bitnami_testlink
      - ALLOW_EMPTY_PASSWORD=yes
    ports:
      - '5003:8080'
      - '443:443'
    depends_on:
      - mariadb

dockerfile模版

FROM centos:7

ADD entrypoint.sh /root

USER root

RUN yum install -y wget vim
RUN yum install -y vim wget
RUN yum install -y wget vim git
RUN yum install -y wget
RUN yum install -y openssh-server openssl
RUN yum install wget vim
RUN yum install git vim

USER jenkins
WORKDIR /root

ENTRYPOINT ["/bin/bash", "/root/entrypoint.sh"]
  1. 搭建普罗米修斯并监控linxu 服务器

  2. 搭建mysql服务并使用mysqld exporter 进行监控并配置好grafana仪表盘

1.通过grafana展示prometheus数据源里node_exporter监控本机linux服务器的性能状态


2.通过grafana展示prometheus数据源里mysqld_exporter监控指定数据库中mysql库的性能状态

关闭