docker-compose數(shù)據(jù)庫監(jiān)控舉例分析

本篇內(nèi)容介紹了“docker-compose數(shù)據(jù)庫監(jiān)控舉例分析”的有關(guān)知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!

創(chuàng)新互聯(lián)公司專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于成都網(wǎng)站制作、做網(wǎng)站、六安網(wǎng)絡(luò)推廣、小程序設(shè)計、六安網(wǎng)絡(luò)營銷、六安企業(yè)策劃、六安品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運營等,從售前售中售后,我們都將竭誠為您服務(wù),您的肯定,是我們最大的嘉獎;創(chuàng)新互聯(lián)公司為所有大學(xué)生創(chuàng)業(yè)者提供六安建站搭建服務(wù),24小時服務(wù)熱線:028-86922220,官方網(wǎng)址:bm7419.com

運維監(jiān)控

監(jiān)控對象:

  • docker

  • redis

  • MySQL

  • nginx

數(shù)據(jù)采集:

  • prometheus

  • cadvisor

  • node-exporter:

  • redis-exporter

  • mysql-exporter:

報表:

  • grafana

nginx 監(jiān)控需要編譯vfs模塊,筆記麻煩!推薦ELK 使用filebeat 直接收集日志,kibana出報表

docker-compose.yml

version: '2'

services:
  # db server
  redis:
    build: redis/
    container_name: redis
    restart: unless-stopped
    volumes:
      - ~/docker/redis/data:/data
      - ~/docker/redis/conf/master/redis.conf:/etc/redis/redis.conf
    ports:
      - "6379:6379"
  
  # mysql:
  #   build: mysql/
  #   container_name: mysql
  #   restart: unless-stopped
  #   volumes:
  #   #  - ~/docker/mysql/data:/var/lib/mysql
  #     - ~/docker/mysql/data:/var/lib/mysql
  #     - ~/github/docker_db/mysql/conf.d:/etc/mysql/conf.d
  #   ports:
  #     - "3306:3306"
  #   environment:
  #     MYSQL_ROOT_PASSWORD: "mysecretpassword"

  # exporter
  cadvisor:
    image: google/cadvisor:latest
    container_name: cadvisor
    restart: unless-stopped
    ports:
      - '8080:8080'
    volumes:
      - /:/rootfs:ro
      - /var/run:/var/run:rw
      - /sys:/sys:ro
      - /var/lib/docker/:/var/lib/docker:ro
  node-exporter:
    image: prom/node-exporter:latest
    container_name: node-exporter
    restart: unless-stopped
    ports:
      - '9100:9100'
    command:
      - '--path.procfs=/host/proc'
      - '--path.sysfs=/host/sys'
      - '--collector.filesystem.ignored-mount-points=^/(sys|proc|dev|host|etc)($$|/)'
      - '--collector.textfile.directory=/node_exporter/prom'
    volumes:
      - /:/rootfs:ro
      - /proc:/host/proc:ro
      - /sys:/host/sys:ro
      - ~/docker/prometheus_exporter/prom:/node_exporter/prom

  # mysql exporter
  # mysql-exporter:
  #   image: prom/mysqld-exporter
  #   container_name: mysql-exporter
  #   hostname: mysql-exporter
  #   user: '0'
  #   restart: always
  #   ports:
  #       - "9104:9104"
  #   environment:
  #     # DATA_SOURCE_NAME: "root:yunjingtest@(localhost:3306)"
  #     DATA_SOURCE_NAME: "root:mysecretpassword@(mysql:23306)"
  #   depends_on:
  #     - mysql

  # redis exporter
  redis-exporter:
    image: oliver006/redis_exporter
    container_name: redis-exporter
    hostname: redis-exporter
    restart: always
    ports:
      - "9121:9121"
    command:
      - "--redis.addr=redis://redis:6379"
    depends_on:
      - redis

  prometheus:
    image: prom/prometheus:latest
    container_name: prometheus
    restart: unless-stopped
    ports:
      - '9090:9090'
    # user: '0'
    command:
      - '--config.file=/etc/prometheus/prometheus.yml'
      - '--storage.tsdb.path=/prometheus/data'
      - '--storage.tsdb.retention=90d'
      - '--web.enable-lifecycle'
    volumes:
      - ./prometheus/conf/prometheus.yml:/etc/prometheus/prometheus.yml
      - ~/docker/prometheus/data:/prometheus/data
    depends_on:
      - cadvisor
      - node-exporter

  grafana:
    image: grafana/grafana:latest
    container_name: grafana
    restart: unless-stopped
    ports:
      - '3000:3000'
    depends_on:
      - prometheus
    volumes:
      - ~/docker/grafana:/var/lib/grafana
    environment:
      - HTTP_USER=admin
      - HTTP_PASS=yunjingtest
      # - GF_SECURITY_ADMIN_PASSWORD=yunjingtest
      # - GF_USERS_ALLOW_SIGN_UP=false
networks:
    db:
        driver: bridge

run:

?  docker_db git:(master) docker-compose up -d
Creating redis         ... done
Creating cadvisor      ... done
Creating node-exporter  ... done
Creating redis-exporter ... done
Creating prometheus     ... done
Creating grafana        ... done
?  docker_db git:(master) docker-compose ps
     Name                   Command               State           Ports
--------------------------------------------------------------------------------
cadvisor         /usr/bin/cadvisor -logtostderr   Up      0.0.0.0:8080->8080/tcp
grafana          /run.sh                          Up      0.0.0.0:3000->3000/tcp
node-exporter    /bin/node_exporter --path. ...   Up      0.0.0.0:9100->9100/tcp
prometheus       /bin/prometheus --config.f ...   Up      0.0.0.0:9090->9090/tcp
redis            docker-entrypoint.sh /usr/ ...   Up      0.0.0.0:6379->6379/tcp
redis-exporter   /redis_exporter --redis.ad ...   Up      0.0.0.0:9121->9121/tcp
?  docker_db git:(master)

web 界面查看

1.prometheus 界面查看job_name

http://localhost:9090/targets docker-compose數(shù)據(jù)庫監(jiān)控舉例分析

2.grafana 查看具體報表

  • redis 狀態(tài)報表

  • prometheus 狀態(tài)報表 dashborad 在granfa官網(wǎng)查找,找到模版id docker-compose數(shù)據(jù)庫監(jiān)控舉例分析

prometheus reids

docker-compose數(shù)據(jù)庫監(jiān)控舉例分析

官方報表模版

監(jiān)控指標(biāo) 模版id:8919

  • cpu

  • 內(nèi)存

  • 磁盤

  • 系統(tǒng)調(diào)用

  • 網(wǎng)絡(luò)io ...

docker-compose數(shù)據(jù)庫監(jiān)控舉例分析

cpu/內(nèi)存:

docker-compose數(shù)據(jù)庫監(jiān)控舉例分析

系統(tǒng)負(fù)載/磁盤/網(wǎng)絡(luò)io

docker-compose數(shù)據(jù)庫監(jiān)控舉例分析

prometheus.yml

# my global config
global:
    scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
    evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
    # scrape_timeout is set to the global default (10s).
  
# Alertmanager configuration
alerting:
  alertmanagers:
  - static_configs:
    - targets:
      # - alertmanager:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus'

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
    - targets: ['localhost:9090']

  - job_name: 'node-exporter'
    scrape_interval: 5s
    static_configs:
    - targets: ['node-exporter:9100']

  - job_name: 'cadvisor'
    scrape_interval: 5s
    static_configs:
    - targets: ['cadvisor:8080']

  # - job_name: 'mysql-exporter'
  #   scrape_interval: 5s
  #   static_configs:
  #   - targets: ['mysql-exporter:9104']

  # - job_name: 'mysql-exporter-100'
  #   scrape_interval: 5s
  #   static_configs:
  #   - targets: ['mysql-exporter-100:9105']

  - job_name: 'redis-exporter'
    scrape_interval: 5s
    static_configs:
    - targets: ['redis-exporter:9121']

“docker-compose數(shù)據(jù)庫監(jiān)控舉例分析”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識可以關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實用文章!

本文題目:docker-compose數(shù)據(jù)庫監(jiān)控舉例分析
文章轉(zhuǎn)載:http://bm7419.com/article4/jccjie.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供營銷型網(wǎng)站建設(shè)、網(wǎng)站策劃標(biāo)簽優(yōu)化、云服務(wù)器外貿(mào)建站、網(wǎng)站收錄

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)