1 服务安装
1.1 下载文件
官网下载地址:prometheus.io/download/
此笔记下载了最新的prometheus-2.42.0.linux-amd64.tar.gz
1.2 安装上传工具
apt install -y lrzsz
1.3 解压
tar vxf prometheus-2.42.0.linux-amd64.tar.gz
1.4 运行
cd prometheus-2.42.0.linux-amd64 && nohup ./prometheus &
1.5 访问
2 主机监控配置
2.1 node_exporter 安装
官网下载地址:prometheus.io/download/#n…
此笔记下载了最新的 node_exporter-1.5.0.linux-amd64.tar.gz
2.2 解压
tar zvxf node_exporter-1.5.0.linux-amd64.tar.gz
2.3 运行
cd node_exporter-1.5.0.linux-amd64 && nohup ./node_exporter &
2.4 访问
2.5 配置
pkill prometheus
vim prometheus.yml
cat prometheus.yml |tail -3
- job_name: "node_exporter"
static_configs:
- targets: ["localhost:9100"]
nohup ./prometheus &
2.6 访问监控
http://127.0.0.1:9090/targets?search=
3 mysql监控配置
3.1 mysqld_exporter 安装
官网下载地址:prometheus.io/download/#m…
此笔记下载了最新的 mysqld_exporter-0.14.0.linux-amd64.tar.gz
3.2 解压
tar zvxf mysqld_exporter-0.14.0.linux-amd64.tar.gz
3.3 运行
cd mysqld_exporter-0.14.0.linux-amd64
chown -R root:root mysqld_exporter
chmod 755 mysqld_exporter
vim .my.cnf
[client]
host=127.0.0.1
port=3306
user=root
password=xxx
vim ./start.sh
#!/bin/bash
nohup ./mysqld_exporter --config.my-cnf=./.my.cnf &
./start.sh
3.4 访问
3.5 配置
pkill prometheus vim prometheus.yml cat prometheus.yml |tail -3 - job_name: "mysqld_exporter" static_configs: - targets: ["localhost:9104"] nohup ./prometheus &
2.6 访问监控
http://127.0.0.1:9090/targets?search=
4 安装grafana
4.1 下载
sudo apt-get install -y adduser libfontconfig1
wget https://dl.grafana.com/enterprise/release/grafana-enterprise_9.3.6_amd64.deb
sudo dpkg -i grafana-enterprise_9.3.6_amd64.deb
4.2 运行
systemctl start grafana-server
systemctl status grafana-server
4.3 访问
http://127.0.0.1:3000/login
默认账号密码:admin/admin
4.4 使用
-
添加数据来源
-
选择Prometheus
-
填入数据来源地址
-
添加完成
-
打开面板
-
新建
-
进入导入页面
-
在仪表盘市场找到你需要的:grafana.com/grafana/das…
-
下载JSON
-
导入即可,以下为MYSQL Exporter的示例