> [TOC] # 监控安装文档 # 1、 `prometheus` 1. 上传`prometheus`安装包至`lab3`服务器`/opt/modules/`目录下并解压 ```shell tar -zxf prometheus-2.32.1.linux-amd64.tar.gz ``` 2. 进入`/opt/modules/prometheus-2.32.1`目录,修改`prometheus.yml`文件 ```shell vi prometheus.yml ``` 将配置信息做如下修改 ```shell scrape_configs: # The job name is added as a label `job=` to any timeseries scraped from this config. - job_name: "prometheus" # metrics_path defaults to '/metrics' # scheme defaults to 'http'. static_configs: - targets: ["lab3:9090"] - job_name: "node exporter" # metrics_path defaults to '/metrics' # scheme defaults to 'http'. static_configs: - targets: ['lab1:8100', 'lab2:8100', 'lab3:8100'] - job_name: "kafka exporter" # metrics_path defaults to '/metrics' # scheme defaults to 'http'. static_configs: - targets: ['lab3:9308'] ``` 3. 在`/opt/modules/prometheus-2.32.1`目录下启动`prometheus` ```shell nohup ./prometheus --config.file=prometheus.yml > ./prometheus.log 2>&1 & ``` 4. 查看`9090`端口状态或浏览器访问`http://lab3:9090`验证是否成功 ```shell lsof -i:9090 ``` # 2、`node_exporter` 1. 上传`node_exporter`安装包至`lab3`服务器`/opt/modules/`目录下并解压 ```shell tar -zxf node_exporter-1.3.1.linux-amd64.tar.gz ``` 2. 进入`/opt/modules/node_exporter-1.3.1`目录,启动`node_exporter` ```shell nohup ./node_exporter --web.listen-address=:8100 & ``` 3. 查看`8100`端口状态或浏览器访问`http://lab3:8100/metrics`验证是否成功 ```shell lsof -i:8100 ``` 4. 在`lab1`和`lab2`上重复上述步骤 # 3、 `kafka_exporter` 1. 上传`kafka_exporter`安装包至`lab3`服务器`/opt/modules/`目录下并解压 ```shell tar -zxf kafka_exporter-1.4.2.linux-amd64.tar.gz ``` 2. 进入`/opt/modules/kafka_exporter-1.4.2`目录,启动`kafka_exporter` ```shell nohup ./kafka_exporter --kafka.server=lab3:9092 > kafka_exporter.log --web.listen-address=:9308 & ``` 3. 查看`9308`端口状态或浏览器访问`http://lab3:9308/metrics`验证是否成功 ```shell lsof -i:9308 ``` # 4、`grafana` 1. 上传`grafana`至`lab3`服务器`/opt/modules/`目录 2. 进入`/opt/modules/grafana-8.3.4`目录,启动`grafana` ```shell nohup ./bin/grafana-server web > ./grafana.log 2>&1 & ``` 3. 查看`3000`端口状态或浏览器访问`http://lab3:3000/`验证是否成功 ```shell lsof -i:3000 ``` 4. 访问`http://lab3:3000`, 用户和密码均为`admin` 5. 进入左侧设置,配置`prometheus`数据源及`mysql`数据源 # 附录 | 软件 | 版本 | 安装位置 | | -------------- | ------ | ---------------- | | prometheus | 2.32.1 | lab3 | | node_exporter | 1.3.1 | lab1,lab2,lab3 | | kafka_exporter | 1.4.2 | lab3 | | grafana | 8.3.4 | lab3 |