[root@docker-p-g prometheus]# ll
总用量 176964
-rw-r--r-- 1 root root 29254678 3月 26 10:37 alertmanager-0.25.0.linux-amd64.tar.gz
drwxr-xr-x 2 3434 3434 109 3月 26 10:48 blackbox_exporter-0.23.0.linux-amd64
-rw-r--r-- 1 root root 10831812 3月 26 10:37 blackbox_exporter-0.23.0.linux-amd64.tar.gz
-rw-r--r-- 1 root root 14688607 3月 26 10:37 graphite_exporter-0.13.3.linux-amd64.tar.gz
drwxr-xr-x 2 3434 3434 129 3月 26 12:01 mysqld_exporter-0.14.0.linux-amd64
-rw-r--r-- 1 root root 7450991 3月 26 10:53 mysqld_exporter-0.14.0.linux-amd64 (1).tar.gz
drwxr-xr-x 2 3434 3434 81 3月 26 10:49 node_exporter-1.5.0.linux-amd64
-rw-r--r-- 1 root root 10181045 3月 26 10:46 node_exporter-1.5.0.linux-amd64.tar.gz
drwxr-xr-x 5 1001 123 190 3月 26 12:09 prometheus-2.43.0.linux-amd64
-rw-r--r-- 1 root root 91091544 3月 26 10:37 prometheus-2.43.0.linux-amd64.tar.gz
drwxr-xr-x 2 3434 3434 77 3月 26 10:50 pushgateway-1.5.1.linux-amd64
-rw-r--r-- 1 root root 10051993 3月 26 10:37 pushgateway-1.5.1.linux-amd64.tar.gz
-rw-r--r-- 1 root root 7636153 3月 26 10:37 statsd_exporter-0.23.1.linux-amd64.tar.gz
cd node_exporter-1.5.0.linux-amd64;ll
echo "nohup ./node_exporter > node_exporter.log 2>&1 &" > node_exporter.start
chmod a+x node_exporter.start
./node_exporter.start
[root@docker-p-g node_exporter-1.5.0.linux-amd64]# ps -ef | grep node_exporter
root 1750 1274 0 10:49 pts/0 00:00:04 ./node_exporter
root 13147 1274 0 12:35 pts/0 00:00:00 grep --color=auto node_exporter
#默认运行在9100
[root@docker-p-g node_exporter-1.5.0.linux-amd64]# ss -utnlp | grep 1750
tcp LISTEN 0 128 :::9100 :::* users:(("node_exporter",pid=1750,fd=3))
mysql内授权
mysql> create user 'exporter'@'%' identified by 'zzz-123-ZZZ';
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'%' WITH MAX_USER_CONNECTIONS 3;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
配置mysqld_exporter连接数据库
mysqld_exporter运行时默认读取运行用户家目录下的.my.cnf文件
笔者用的root用户
配置.my.cnf文件
参考1
参考2
vim /root/.my.cnf
[client]
host=192.168.44.180
port=3306
user=exporter
password=zzz-123-ZZZ
配置运行mysqld_exporter
cd mysqld_exporter-0.14.0.linux-amd64
echo "nohup ./mysqld_exporter > mysqld_exporter.log 2>&1 &" > mysqld_exporter.start
chmod a+x mysqld_exporter.start
./mysqld_exporter.start
[root@docker-p-g mysqld_exporter-0.14.0.linux-amd64]# ps -ef | grep mysqld_exporter
root 13051 1 0 12:07 pts/1 00:00:06 ./mysqld_exporter
root 13190 1839 0 12:47 pts/1 00:00:00 grep --color=auto mysqld_exporter
#mysqld_exporter默认为9104
[root@docker-p-g mysqld_exporter-0.14.0.linux-amd64]# ss -utnlp | grep 13051
tcp LISTEN 0 128 :::9104 :::* users:(("mysqld_exporter",pid=13051,fd=3))
cd prometheus-2.43.0.linux-amd64
vim prometheus.yml
新增exporter配置
- job_name: "node_local"
static_configs:
- targets: ["localhost:9100"]
- job_name: "mysql_local"
static_configs:
- targets: ["localhost:9104"]
echo "nohup ./prometheus > prometheus.log 2>&1 &" > prometheus.start
./prometheus.start
[root@docker-p-g prometheus-2.43.0.linux-amd64]# ps -ef | grep prometheus
root 13068 1 0 12:09 pts/0 00:00:03 ./prometheus
root 13206 1839 0 12:53 pts/1 00:00:00 grep --color=auto prometheus
#prometheus默认9090
[root@docker-p-g prometheus-2.43.0.linux-amd64]# ss -utnlp | grep 13068
tcp LISTEN 0 128 :::9090 :::* users:(("prometheus",pid=13068,fd=7))
http://192.168.44.180:9100/metrics
http://192.168.44.180:9104/metrics
[root@docker-p-g prometheus-2.43.0.linux-amd64]# cd /data/grafana/
[root@docker-p-g grafana]# ll
总用量 77584
-rw-r--r-- 1 root root 79444031 3月 26 11:08 grafana-9.0.0-1.x86_64.rpm
[root@docker-p-g grafana]# yum -y install grafana-9.0.0-1.x86_64.rpm
[root@docker-p-g grafana]# systemctl start grafana-server.service
[root@docker-p-g grafana]# systemctl status grafana-server.service
● grafana-server.service - Grafana instance
Loaded: loaded (/usr/lib/systemd/system/grafana-server.service; disabled; vendor preset: disabled)
Active: active (running) since 日 2023-03-26 11:13:09 CST; 1h 49min ago
Docs: http://docs.grafana.org
Main PID: 2526 (grafana-server)
CGroup: /system.slice/grafana-server.service
└─2526 /usr/sbin/grafana-server --config=/etc/grafana/grafana.ini --pidfile=/var/run/grafana/grafana-server.pid --packaging=rpm cfg:default.paths.log...
3月 26 12:12:55 docker-p-g grafana-server[2526]: logger=context traceID=00000000000000000000000000000000 userId=1 orgId=1 uname=admin t=2023-03-26T12:12:55.255...
3月 26 12:13:05 docker-p-g grafana-server[2526]: logger=context traceID=00000000000000000000000000000000 userId=1 orgId=1 uname=admin t=2023-03-26T12:...000000000
3月 26 12:13:05 docker-p-g grafana-server[2526]: logger=context traceID=00000000000000000000000000000000 userId=1 orgId=1 uname=admin t=2023-03-26T12:13:05.490...
3月 26 12:13:05 docker-p-g grafana-server[2526]: logger=context traceID=00000000000000000000000000000000 userId=1 orgId=1 uname=admin t=2023-03-26T12:...000000000
3月 26 12:13:05 docker-p-g grafana-server[2526]: logger=context traceID=00000000000000000000000000000000 userId=1 orgId=1 uname=admin t=2023-03-26T12:13:05.506...
3月 26 12:13:09 docker-p-g grafana-server[2526]: logger=context traceID=00000000000000000000000000000000 userId=1 orgId=1 uname=admin t=2023-03-26T12:...000000000
3月 26 12:13:09 docker-p-g grafana-server[2526]: logger=context traceID=00000000000000000000000000000000 userId=1 orgId=1 uname=admin t=2023-03-26T12:13:09.902...
3月 26 12:13:10 docker-p-g grafana-server[2526]: logger=context traceID=00000000000000000000000000000000 userId=1 orgId=1 uname=admin t=2023-03-26T12:13:10.172...
3月 26 12:13:10 docker-p-g grafana-server[2526]: logger=context traceID=00000000000000000000000000000000 userId=1 orgId=1 uname=admin t=2023-03-26T12:13:10.191...
3月 26 12:13:10 docker-p-g grafana-server[2526]: logger=live t=2023-03-26T12:13:10.203636377+08:00 level=info msg="Initialized channel handler" channe...rYdddlPWk
Hint: Some lines were ellipsized, use -l to show in full.
#grafana默认3000
[root@docker-p-g grafana]# ss -utnlp | grep 2526
tcp LISTEN 0 128 :::3000 :::* users:(("grafana-server",pid=2526,fd=14))
默认admin/admin