prometheus部署教程(一)

1、prometheus 安装

(1)下载文件:

# wget https://github.com/prometheus/prometheus/releases/tag/v3.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 https://github.com/prometheus/node_exporter/releases/download/v1.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等,请各位大佬指教。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值