监控神器普罗米修斯Prometheus安装配置
1.安装go
wget https://golang.org/dl/go1.16.linux-amd64.tar.gz
tar xf go1.16.linux-amd64.tar.gz -C /usr/local/
cat /etc/profile
export PATH=$PATH:/usr/local/go/bin
source /etc/profile
go version
返回值 go version go1.16 linux/amd64
2.部署Linux远程监控主机插件
在被监控端上安装node_exporter组件
下载地址: https://prometheus.io/download 或者 https://github.com/prometheus/node_exporter
wget https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz
tar xf node_exporter-0.18.1.linux-amd64.tar.gz -C /mvw/app/
cd /mvw/app/node_exporter-0.18.1.linux-amd64/
nohup ./node_exporter &
出现如下日志表示启动成功

监控mysql的插件:
https://github.com/prometheus/mysqld_exporter/releases
监控服务端口地址:
https://github.com/prometheus/blackbox_exporter/releases
3.安装Prometheus
搜索官网: https:///prometheus.io/
wget https://github.com/prometheus/prometheus/releases/download/v2.25.0/prometheus-2.25.0.linux-amd64.tar.gz
tar xf prometheus-2.25.0.linux-amd64.tar.gz -C/mvw/app/
ln -s prometheus-2.25.0.linux-amd64 /mvw/app/prometheus
普罗米修斯默认配置文件 vim /mvw/app/Prometheus/prometheus.yml
在scrape_configs配置项下添加Linux监控的job,其中 IP修改为上面部署 node_exporter机器的ip,端口号为9100,注意缩进

启动:
cd /mvw/app/prometheus
nohup ./prometheus &
出现如下日志表示启动成功

在浏览器中访问部署的prometheus:http://{ip}:9090
点击菜单栏“Status-Targets”,看到页面中有如下node节点,代表prometheus和node_exporter链接成功

通过浏览器访问http://被监控端IP:9100/metrics就可以查看到node_exporter在被监控端收集的监控信息

或者启容器
docker run --name prometheus -d -p 9090:9090 quay.io/prometheus/prometheus
浏览器打开IP:9090端口即可打开普罗米修斯自带的监控页面
4.安装Grafana
普罗米修斯默认的页面可能没有那么直观,我们可以安装grafana使监控看起来更直观
下载地址:https://grafana.com/grafana/download

wget https://dl.grafana.com/oss/release/grafana-8.5.3-1.x86_64.rpm
yum install grafana-8.5.3-1.x86_64.rpm
启动:
sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable grafana-server.service
sudo /bin/systemctl start grafana-server.service
报错:
sudo /bin/systemctl daemon-reload
Authorization not available. Check if polkit service is running or see debug message for more information.
Failed to execute operation: 连接超时
yum install polkit -y
在次启动:
sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable grafana-server.service
sudo /bin/systemctl start grafana-server.service
查看端口3000
访问grafana:
浏览器访问IP:3000端口,即可打开grafana页面,默认用户名密码都是admin,初次登录会要求修改默认的登录密码
我们把prometheus服务器收集的数据做为一个数据源添加到grafana,让grafana可以得到prometheus的数据



- Grafana图形显示Linux硬件信息
Grafana官方提供模板地址:https://grafana.com/grafana/dashboards
要导入的模板:https://grafana.com/grafana/dashboards/11074
Grafana导入监控模板
图片.png
图片.png
选择导入成功的模板查看
图片.png
图片.png