一、介绍
略
二、安装prometheus及exporter
Mysqld被监控端安装
yum -y install mariadb-server
tar -zxvf mysqld_exporter-0.11.0.linux-amd64.tar.gz
cd mysqld_exporter-0.11.0.linux-amd64
ln -s /root/mysqld_exporter-0.11.0.linux-amd64/mysqld_exporter /bin/
systemctl start mariadb
mysql -uroot -p -e "grant replication client,process on *.* to 'mysql_monitor'@'%' identified by '123';"
vi /etc/my.cnf.d/client.cnf
[client]
user=mysql_monitor
password=123
——————————————————————————
运行mysqld监控端
[root@localhost ~]# mysqld_exporter --config.my-cnf=/etc/my.cnf.d/client.cnf
INFO[0000] Starting mysqld_exporter (version=0.11.0, branch=HEAD, revision=5d7179615695a61ecc3b5bf90a2a7c76a9592cdd) source="mysqld_exporter.go:206"
INFO[0000] Build context (go=go1.10.3, user=root@3d3ff666b0e4, date=20180629-15:00:35) source="mysqld_exporter.go:207"
INFO[0000] Enabled scrapers: source="mysqld_exporter.go:218"
INFO[0000] --collect.global_status source="mysqld_exporter.go:222"
INFO[0000] --collect.global_variables source="mysqld_exporter.go:222"
INFO[0000] --collect.slave_status source="mysqld_exporter.go:222"
INFO[0000] --collect.info_schema.tables source="mysqld_exporter.go:222"
INFO[0000] Listening on :9104 source="mysqld_exporter.go:232"
服务端安装
(1)安装prometheus
yum -y install prometheus
(2)添加监控点
[root@node4 ~]# grep -Ev "^[[:space:]]*(#|$)" /etc/prometheus/prometheus.yml
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.
alerting:
alertmanagers:
- static_configs:
- targets:
rule_files:
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'mysqld'
static_configs:
- targets: ['192.168.168.122:9104']
(3)运行prometheus
prometheus --config.file=/etc/prometheus/prometheus.yml --log.level=debug
三、安装grafana并添加监控项绘图
yum -y install grafana-enterprise
systemctl start grafana-server
用浏览器打开grafana服务器的ip:3000

使用默认用户名密码admin/admin登录
四、注意事项
无
Leave a Reply