Prometheus监控安装

Prometheus监控

一 环境准备

例:Prometheus服务器(192.168.1.171),Agent被监控服务器(192.168.1.172)

 

二、安装Prometheus(192.168.1.171)

1.下载Prometheus安装包

wget https://github.com/prometheus/prometheus/releases/download/v2.17.2/prometheus-2.17.2.linux-amd64.tar.gz

2.解压并安装软件

tar -zxvf prometheus-2.17.2.linux-amd64.tar.gz
mv prometheus-2.17.2.linux-amd64 /usr/local/prometheus

3.启动Prometheus

cd /usr/local/prometheus
./prometheus --config.file="/usr/local/prometheus/prometheus.yml" &

 

三、监控agent主机(192.168.1.172)

1.安装node_exporter

wget https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz

2.解压并安装软件

tar -zxvf node_exporter-0.18.1.linux-amd64.tar.gz
mv node_exporter-0.18.1.linux-amd64 /usr/local/node_exporter

3.启动node_exporter

cd /usr/local/node_exporter/
nohup ./node_exporter &

4.确认端口9100

ss -anlpt|grep 9100

 

四、监控agent的mysqld服务(192.168.1.172)

1.mysql安装(省略)

2.安装mysqld_exporter

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

3.解压并安装软件

tar -zxvf mysqld_exporter-0.12.1.linux-amd64.tar.gz
mv mysqld_exporter-0.12.1.linux-amd64 /usr/local/mysqld_exporter

4.配置mysql信息

cd /usr/local/mysqld_exporter
vim .my.cnf
​
[client]
user=root
password=root

5.启动mysqld_exporter

nohup /usr/local/mysqld_exporter/mysqld_exporter --config.my-cnf=/usr/local/mysqld_exporter/.my.cnf &

6.确认端口9104

lsof -i :9104

 

五、重新配置启动prometheus(192.168.1.171)

1.关闭Prometheus

pkill prometheus

2.进入/usr/local/prometheus编辑prometheus.yml配置文件

- job_name: 'ali-agent'
    static_configs:
    - targets: ['192.168.1.172:9100']
    
- job_name: 'ali-mysql'
    static_configs:
    - targets: ['192.168.1.172:9104']

3.启动Prometheus

/usr/local/prometheus/prometheus --config.file="/usr/local/prometheus/prometheus.yml" &

4.确认端口9090

lsof -i:9090

 

六、进入浏览器页面查看验证(192.168.1.171:9090/targets)

 

你可能感兴趣的:(Linux,Prometheus)