prometheus部署教程(一)
prometheus IP | 被监控主机ip |
---|---|
192.168.43.166 | 192.168.43.149 |
1、prometheus 安装
(1)下载文件:
# wget .2.1/prometheus-3.2.1.linux-amd64.tar.gz
(2)解压安装包:
[root@localhost ~]#tar xvf prometheus-3.2.1.linux-amd64.tar.gz -C /usr/local/
[root@localhost ~]#mv /usr/local/ prometheus-3.2.1.linux-amd64 /usr/local/prometheus
(3)创建数据启动和数据目录
[root@localhost ~]#mkdir -p /etc/prometheus /var/lib/prometheus
[root@localhost ~]#cp /usr/local/prometheus/prometheus.yml /etc/prometheus/
(4)创建service文件:
[root@localhost ~]#vim /etc/systemd/system/prometheus.service
[Unit]
Description=Prometheus Monitoring System
After=network.target
[Service]
ExecStart=/usr/local/prometheus/prometheus \
--config.file=/etc/prometheus/prometheus.yml \
--storage.tsdb.path=/var/lib/prometheus \
--web.listen-address=:9090 \
--web.enable-lifecycle
Restart=on-failure
[Install]
WantedBy=multi-user.target
(5)重载配置并启动服务
systemctl daemon-reload
systemctl start prometheus
systemctl enable prometheus
systemctl status prometheus
(6)关闭防火墙
(7)页面上访问
2、监控主机(node_exporter)安装
(1)下载安装包
下载并解压:
wget .6.1/node_exporter-1.6.1.linux-amd64.tar.gz
[root@localhost ~]# tar -zxvf node_exporter-1.6.1.linux-amd64.tar.gz -C /usr/local/
[root@localhost ~]# mv /usr/local/node_exporter-1.6.1.linux-amd64 /usr/local/node_exporter
(2)创建service文件:
[root@localhost ~]# vi /etc/systemd/system/node_exporter.service
[Unit]
Description=node_exporter
After=network.target
[Service]
User=root
ExecStart=/usr/local/node_exporter/node_exporter
Restart=on-failure
[Install]
WantedBy=multi-user.target
(3)重载配置并启动服务
[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl start node_exporter
(4)关闭防火墙
(5)在promethues的配置文件上添加主机信息
[root@localhost ~]# vim /etc/prometheus/prometheus.yml
(6)重启promethues
(7)登录prometheus页面查看主机已经被监控到了
到此prometheus监控主机的配置已完成,
3、验证cpu,内存,存储
(1)cpu信息
(2)内存信息
(3)存储信息
页面上还可以查看网络,io,端口等主机信息都可以监控,这里不一一展示。
接下来分享mysql_exporter,redis_exporter和grafana等,请各位大佬指教。
发布评论