Prometheus 的安装还是比较简单的
下载地址如下
https://prometheus.io/download/
解压, 修改配置, 运行. 默认监听 9090 端口
- [[email protected] ~]# tar -xvf prometheus-2.14.0.Linux-amd64.tar.gz
- [[email protected] ~]# cd prometheus-2.14.0.Linux-amd64
- [[email protected] prometheus-2.14.0.Linux-amd64]# cat prometheus.YAML |grep 9090 #因为我需要在外部访问, 所以把以下部分的 localhost 修改为服务器 IP
- - targets: ['192.168.100.128:9090']
- [[email protected] prometheus-2.14.0.Linux-amd64]# ./prometheus
访问 web
查看能否正常监控到数据. state 为 up 则为监控正常
下面我们尝试监控 MySQL
部署安装配置 MySQL 的步骤就滤过了. 都是老生常谈. 数据库账号密码 root/123456
下载 mysqld_exporter
https://prometheus.io/download/#mysqld_exporter
解压, 配置连接 MySQL 的信息, 运行. 默认监听 9104 端口
- [[email protected] ~]# tar -xvf mysqld_exporter-0.ar.gz
- [[email protected] ~]# cat /root/.my.cnf
- [client]
- host=127.0.0.1
- user=root
- password=123456
- [[email protected] ~]# cd mysqld_exporter-0.12.1.Linux-amd64
- [[email protected] mysqld_exporter-0.12.1.Linux-amd64]#mysqld_exporter
访问 9104 端口, 看能否正常访问到
现在我们让 Prometheus 监控 MySQL. 只需修改 YAML 文件, 把 9090 修改为 9104 端口即可
- [[email protected] prometheus-2.14.0.Linux-amd64]# grep 9104 prometheus.YAML
- - targets: ['192.168.100.128:9104']
- [[email protected] prometheus-2.14.0.Linux-amd64]#
修改以上配置后重启 Prometheus. 页面刷新后自动修改为监控 9104 端口了
配置 grafana
安装并启动 grafana. 默认监听 3000 端口
- wget https://dl.grafana.com/oss/release/grafana-6.4.4-1.x86_64.rpm
- yum install grafana-6.4.4-1.x86_64.rpm
- systemctl start grafana-server
配置 grafana 显示 Prometheus 数据
来源: http://www.bubuko.com/infodetail-3296389.html