1. 从官网选择Prometheus版本进行下载
官网地址 https://github.com/prometheus/prometheus/releases/
2. 实验安排
在主机192.168.153.137上安装prometheus监控192.168.153.138上的mysql服务和主机状态
3. 上传软件包到137服务器并配置
3.1 将软件包解压到 /usr/local 目录下
tar xzf prometheus-2.24.1.linux-amd64.tar.gz -C /usr/local/
3.2 给目录创建软链接
ln -s /usr/local/prometheus-2.24.1.linux-amd64/ /usr/local/prometheus
3.3 切换到目录下
cd /usr/local/prometheus
3.4 修改配置文件 prometheus.yml
,配置要监控的项
scrape_configs: # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config. - job_name: 'prometheus' # metrics_path defaults to '/metrics' # scheme defaults to 'http'. static_configs: - targets: ['localhost:9090'] #监控Linux主机状态 - job_name: 'linux' static_configs: - targets: ['192.168.153.138:9100'] #监控mysql服务状态 - job_name: 'mysql' static_configs: - targets: ['192.168.153.138:9104']
3.5 启动promethus服务
./prometheus --config.file=prometheus.yml
3.6 浏览器输入 IP:9090
查看
在Status->Targets
页面下,我们可以看到我们配置的两个Target,它们的State为DOWN。
4. 配置138主机 4.1 下载exporter
下载地址 https://github.com/prometheus/node_exporter/releases
4.2 将软件包解压到 /usr/local 目录下
tar xzf node_exporter-1.0.1.linux-amd64.tar.gz -C /usr/local/
4.3 启动exporter
nohup /usr/local/node_exporter-1.0.1.linux-amd64/node_exporter &
4.4 下载mysqld_exporter
下载地址 https://github.com/prometheus/mysqld_exporter/releases
4.5 将软件包解压到 /usr/local 目录下
tar xzf mysqld_exporter-0.12.1.linux-amd64.tar.gz -C /usr/local/
4.6 数据库给mysqld_exporter授权
[root@host-138 ~]# mysql Welcome to the MariaDB monitor. Commands end with ; or \g. MariaDB [(none)]> GRANT REPLICATION CLIENT,PROCESS ON *.* TO 'mysql_monitor'@'localhost' identified by 'mysql_monitor'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> GRANT SELECT ON *.* TO 'mysql_monitor'@'localhost'; Query OK, 0 rows affected (0.00 sec)
4.7 创建 .my.cnf
配置文件
vim /usr/local/mysqld_exporter-0.12.1.linux-amd64/.my.cnf
内容为:
[client] user=mysql_monitor password=mysql_monitor
4.8 运行mysqld_exporter服务
nohup /usr/local/mysqld_exporter-0.12.1.linux-amd64/mysqld_exporter --config.my-cnf="/usr/local/mysqld_exporter-0.12.1.linux-amd64/.my.cnf" &
5. 在promethus页面刷新Status->Targets页面,可以看到配置的两个Target的State为UP:
5. 在137主机上安装部署grafana
安装教程链接https://www.jb51.net/article/204660.htm
5.1 添加promethus数据源 未完待续…
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
更新日志
- 群星.2006-失而复得2辑【新艺宝】【WAV+CUE】
- 《张震岳6CD合集》1993-2000全套[WAV+CUE][3.1G]
- 周华健《粤语精选+国语精选》日本母带 [WAV+CUE][1.2G]
- 《陈楚生6CD合集》[WAV+CUE][2.2G]
- dnf经验胶囊快速获得
- dnf结婚地下城入场材料怎么获得
- dnf结婚戒指属性和婚房属性
- FlorianNoack-IWannaBeLikeYou(2024)【Hi-Res】24bit-96kHz【flac】
- 张国荣.1995-狂恋·国语经典【新艺宝】【WAV+CUE】
- 佛教音乐.2012-《藏传密咒精选集》[FLAC+CUE]
- 微软在Win11中加入内置广告:宣传XGP服务
- 《地狱之刃2》官方:游戏中美景都是取材于真实地点
- 对漫威太失望!叉骨叔确认加盟DC《和平使者》第2季
- 李克勤.1998-寻最这五年2CD【艺能动音】【WAV+CUE】
- 彭莉.1995-感谢你的爱【宝丽金】【WAV+CUE】