一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

服務器之家:專注于服務器技術及軟件下載分享
分類導航

Linux|Centos|Ubuntu|系統進程|Fedora|注冊表|Bios|Solaris|Windows7|Windows10|Windows11|windows server|

服務器之家 - 服務器系統 - Linux - 運維監控系統之Prometheus-MySQL監控

運維監控系統之Prometheus-MySQL監控

2020-12-30 00:11今日頭條linux運維菜 Linux

Prometheus 是一個開源的服務監控系統和時間序列數據庫。本文主要為大家介紹運維監控系統之Prometheus-MySQL監控,有需要的朋友可以參考下

 簡介

mysqld_exporter是用于獲取mysql實例的指標服務。

運維監控系統之Prometheus-MySQL監控

安裝

運維監控系統之Prometheus-MySQL監控

mysql授權

CREATE USER exporter@localhost identified by "mima"

GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'localhost' WITH MAX_USER_CONNECTIONS 3; 

flush privileges

直接通過命令下載就可以了。

wget -t 1000 -c https://github.com/prometheus/mysqld_exporter/releases/download/v0.12.1/mysqld_exporter-0.12.1.linux-amd64.tar.gz 

tar zxvf  mysqld_exporter-0.12.1.linux-amd64.tar.gz -C /opt/ 

cd /opt/mysqld_exporter-0.12.1.linux-amd64 

export DATA_SOURCE_NAME='exporter:mima@(localhost:3306)/' 

./mysqld_exporter 

這里設置用戶名密碼是通過環境變量的形式,也可以用配置文件,默認找的配置文件是~/.my.cnf,也可以使用參數--config.my-cnf="/opt/mysqld_exporter/.my.cnf" 進行設置。

./mysqld_exporter --config.my-cnf="/opt/mysqld_exporter/.my.cnf" 

其他參數

usage: mysqld_exporter [<flags>] 

 

Flags: 

  -h, --help                   Show context-sensitive help (also try --help-long and --help-man). 

      --exporter.lock_wait_timeout=2   

                               Set a lock_wait_timeout on the connection to avoid long metadata locking. 

      --exporter.log_slow_filter   

                               Add a log_slow_filter to avoid slow query logging of scrapes. NOTE: Not supported by Oracle MySQL

      --collect.heartbeat.database="heartbeat"   

                               Database from where to collect heartbeat data 

      --collect.heartbeat.table="heartbeat"   

                               Table from where to collect heartbeat data 

      --collect.info_schema.processlist.min_time=0   

                               Minimum time a thread must be in each state to be counted 

      --collect.info_schema.processlist.processes_by_user   

                               Enable collecting the number of processes by user 

      --collect.info_schema.processlist.processes_by_host   

                               Enable collecting the number of processes by host 

      --collect.info_schema.tables.databases="*"   

                               The list of databases to collect table stats foror '*' for all 

      --collect.mysql.user.privileges   

                               Enable collecting user privileges from mysql.user 

      --collect.perf_schema.eventsstatements.limit=250   

                               Limit the number of events statements digests by response time 

      --collect.perf_schema.eventsstatements.timelimit=86400   

                               Limit how old the 'last_seen' events statements can be, in seconds 

      --collect.perf_schema.eventsstatements.digest_text_limit=120   

                               Maximum length of the normalized statement text 

      --collect.perf_schema.file_instances.filter=".*"   

                               RegEx file_name filter for performance_schema.file_summary_by_instance 

      --collect.perf_schema.file_instances.remove_prefix="/var/lib/mysql/"   

                               Remove path prefix in performance_schema.file_summary_by_instance 

      --web.listen-address=":9104"   

                               Address to listen on for web interface and telemetry. 

      --web.telemetry-path="/metrics"   

                               Path under which to expose metrics. 

      --timeout-offset=0.25    Offset to subtract from timeout in seconds. 

      --config.my-cnf="/home/jalright/.my.cnf"   

                               Path to .my.cnf file to read MySQL credentials from

      --collect.mysql.user     Collect data from mysql.user 

      --collect.info_schema.tables   

                               Collect metrics from information_schema.tables 

      --collect.info_schema.innodb_tablespaces   

                               Collect metrics from information_schema.innodb_sys_tablespaces 

      --collect.info_schema.innodb_metrics   

                               Collect metrics from information_schema.innodb_metrics 

      --collect.global_status  Collect from SHOW GLOBAL STATUS 

      --collect.global_variables   

                               Collect from SHOW GLOBAL VARIABLES 

      --collect.slave_status   Collect from SHOW SLAVE STATUS 

      --collect.info_schema.processlist   

                               Collect current thread state counts from the information_schema.processlist 

      --collect.perf_schema.tablelocks   

                               Collect metrics from performance_schema.table_lock_waits_summary_by_table 

      --collect.perf_schema.eventsstatements   

                               Collect metrics from performance_schema.events_statements_summary_by_digest 

      --collect.perf_schema.eventsstatementssum   

                               Collect metrics of grand sums from performance_schema.events_statements_summary_by_digest 

      --collect.perf_schema.eventswaits   

                               Collect metrics from performance_schema.events_waits_summary_global_by_event_name 

      --collect.auto_increment.columns   

                               Collect auto_increment columns and max values from information_schema 

      --collect.binlog_size    Collect the current size of all registered binlog files 

      --collect.perf_schema.tableiowaits   

                               Collect metrics from performance_schema.table_io_waits_summary_by_table 

      --collect.perf_schema.indexiowaits   

                               Collect metrics from performance_schema.table_io_waits_summary_by_index_usage 

      --collect.info_schema.userstats   

                               If running with userstat=1, set to true to collect user statistics 

      --collect.info_schema.clientstats   

                               If running with userstat=1, set to true to collect client statistics 

      --collect.info_schema.tablestats   

                               If running with userstat=1, set to true to collect table statistics 

      --collect.info_schema.schemastats   

                               If running with userstat=1, set to true to collect schema statistics 

      --collect.perf_schema.file_events   

                               Collect metrics from performance_schema.file_summary_by_event_name 

      --collect.perf_schema.file_instances   

                               Collect metrics from performance_schema.file_summary_by_instance 

      --collect.perf_schema.replication_group_member_stats   

                               Collect metrics from performance_schema.replication_group_member_stats 

      --collect.perf_schema.replication_applier_status_by_worker   

                               Collect metrics from performance_schema.replication_applier_status_by_worker 

      --collect.engine_innodb_status   

                               Collect from SHOW ENGINE INNODB STATUS 

      --collect.heartbeat      Collect from heartbeat 

      --collect.slave_hosts    Scrape information from 'SHOW SLAVE HOSTS' 

      --collect.info_schema.innodb_cmp   

                               Collect metrics from information_schema.innodb_cmp 

      --collect.info_schema.innodb_cmpmem   

                               Collect metrics from information_schema.innodb_cmpmem 

      --collect.info_schema.query_response_time   

                               Collect query response time distribution if query_response_time_stats is ON

      --collect.engine_tokudb_status   

                               Collect from SHOW ENGINE TOKUDB STATUS 

      --log.level="info"       Only log messages with the given severity or above. Valid levels: [debug, info, warn, error, fatal] 

      --log.format="logger:stderr"   

                               Set the log target and format. Example: "logger:syslog?appname=bob&local=7" or "logger:stdout?json=true" 

      --version                Show application version. 

部署服務

直接注冊成systemd服務。

```bash 

#!/bin/bash 

 

VERSION="0.12.1" 

 

wget  -t 100  -c  https://github.com/prometheus/mysqld_exporter/releases/download/v${VERSION}/mysqld_exporter-${VERSION}.linux-amd64.tar.gz 

 

if [ ! -e mysqld_exporter-${VERSION}.linux-amd64.tar.gz ] 

then 

    echo "安裝包下載失敗" 

    exit 1 

fi 

tar xvfz mysqld_exporter-${VERSION}.linux-amd64.tar.gz -C /opt/ 

cd /opt 

ln -s mysqld_exporter-${VERSION}.linux-amd64  mysqld_exporter 

cat > /etc/systemd/system/mysqld_exporter.service <<EOF 

 

[Unit] 

Description=mysqld_exporter 

After=network.target 

 

[Service] 

Type=simple 

WorkingDirectory=/opt/mysqld_exporter 

ExecStart=/opt/mysqld_exporter/mysqld_exporter --config.my-cnf="/opt/mysqld_exporter/.my.cnf" 

LimitNOFILE=65536 

PrivateTmp=true 

RestartSec=2 

StartLimitInterval=0 

Restart=always 

 

[Install] 

WantedBy=multi-user.target 

EOF 

?``` 

systemctl daemon-reload 

systemctl enable mysqld_exporter 

systemctl start mysqld_exporter 

 配置prometheus Job

默認端口是9104

- job_name: 'mysqld_exporter' 

 

  # metrics_path defaults to '/metrics' 

  # scheme defaults to 'http'

 

  static_configs: 

  - targets: ['localhost:9104'

指標展示

指標可以通過prometheus的WebUI進行查看

http://[promethe server ip]:9090 

如果需要畫圖,可以直接使用grafana,有人已經配置好了圖形可以通過grafana官方下的dashboard找到mysqld_exporter相關的dashboard就可以直接使用了,配置好prometheus數據源,直接導入grafana就可以直接展示了。

運維監控系統之Prometheus-MySQL監控

原文地址:https://www.toutiao.com/i6911310105698943491/

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 男女乱淫真视频播放网站 | 日本免费三片在线播放 | 四虎精品永久在线网址 | 欧洲vodafonewi精品 | 四虎永久在线精品波多野结衣 | 5g在线观看 | 秀婷程仪公欲息肉婷在线观看 | 亚洲色图欧美偷拍 | 国产欧美va欧美va香蕉在线观看 | 色网在线观看 | 亚洲AV无码一区二区三区乱子伦 | 天堂在线观看中文字幕 | 大陆日韩欧美 | 国产日韩在线 | 欧美男人的天堂 | 人妖三级 | 91视频国产自拍 | 亚洲国产精品综合欧美 | 奇米影视久久777中文字幕 | 欧美日韩一区二区中文字幕视频 | 国产成人亚洲精品91专区手机 | 日韩一区二区中文字幕 | 国产欧美日韩在线观看精品 | 99九九精品视频 | 免费看一级a一片毛片 | 天生奶水1v1高h | 无码乱人伦一区二区亚洲一 | 99久在线| 午夜精品在线视频 | 美国女艳星brandilove | 无码专区aaaaaa免费视频 | 男神插曲女生动漫完整版动漫 | 66j8影院xxxx深夜| 色综合天天综合网看在线影院 | 99精品偷自拍| 免费老外的毛片清高 | 日本aaaa级 | 亚洲系列第一页 | 国产精品不卡高清在线观看 | 91插插插插 | 欧美日韩高清不卡一区二区三区 |