Prometheus+node_exporter+grafana部署安装

一、准备环境

本次redis3.2.13版本集群搭建采用一台虚机,以192.168.190.148虚机为例

虚机配置:

机器IP CPU&内存 系统盘 备注
192.168.190.148Flink1 2C4G 50GB 建议最低配置

二、详细步骤

目前以192.168.190.148虚机为例:

1、检查虚机防火墙是否关闭

systemctl status firewalld

如果没有关闭:

①、临时关闭:systemctl stop firewalld

②、永久关闭:systemctl disable firewalld

2、创建必要的目录

mkdir /pro

3、编辑基础配置环境

yum -y install go

4、安装并配置Prometheus

网址:https://prometheus.io/download/

①、解压并重命名:

tar -xvf prometheus-2.53.1.linux-amd64.tar.gz

mv prometheus-2.53.1.linux-amd64 prometheus

②、进入Prometheus目录下,编辑prometheus.yml文件:

将localhost:9090修改为192.168.190.148:9090

③、启动Prometheus:

./prometheus --config.file=/usr/local/prometheus/prometheus.yml

④、添加服务并设置开机启动:

vi /etc/systemd/system/prometheus.service

[Unit]

Description=Prometheus

Documentation=https://prometheus.io/

After=network.target

[Service]

Type=simple

User=root

ExecStart=/pro/prometheus/prometheus --config.file=/pro/prometheus/prometheus.yml

Restart=on-failure

[Install]

WantedBy=multi-user.target

详情参照附件:

[prometheus.service]

编辑完成后按顺序执行:

A、pkill prometheus  ##终止Prometheus进程(因为第③步启动了Prometheus)

B、systemctl daemon-reload  ##重新加载systemd服务

C、systemctl enable prometheus.service  ##设置开机启动

D、systemctl start prometheus.service  ##启动Prometheus

E、systemctl status prometheus.service  ##查看Prometheus状态

全部执行完成之后可打开网页:http://192.168.190.148:9090(http://本机IP:9090)

5、安装并配置常用监控exporter

下载网址:https://prometheus.io/download/

①、解压并重命名

tar -xvf node_exporter-1.8.2.linux-amd64.tar.gz

mv node_exporter-1.8.2.linux-amd64 node_exporter

②、启动node_exporter服务

cd node_exporter

./node_exporter

③、添加服务并设置开机启动:

[Unit]

Description=prometheus server daemon

[Service]

ExecStart=/pro/node_exporter/node_exporter

Restart=on-failure

[Install]

WantedBy=multi-user.target

详情请参考附件:

[node_exporter.service]

编辑完成后按顺序执行:

A、systemctl daemon-reload  ##重新加载systemd服务

B、systemctl enable node_exporter.service  ##设置开机启动

C、systemctl start node_exporter.service  ##启动Prometheus

D、systemctl status node_exporter.service  ##查看Prometheus状态

④、node监控的端口为9100,配置Prometheus的yml文件:

vi /pro/prometheus/prometheus.yml

  - job_name: "主机节点"

    static_configs:

 - targets: ["192.168.190.148:9100"]

    labels:

       instance: node

详情请参考附件:

[prometheus.yml]

⑤、配置完成保存退出后,重启Prometheus:

systemctl stop prometheus

systemctl start prometheus

6、安装并配置grafana

网址:

wget https://dl.grafana.com/enterprise/release/grafana-enterprise-8.5.2-1.x86_64.rpm

①、安装依赖环境:

yum -y install chkconfig

②、解压:

rpm -ivh grafana-enterprise-8.5.2-1.x86_64.rpm

③、启动grafana:

systemctl start grafana-server.service  ##启动grafana

systemctl status grafana-server.service  ##查看grafana状态

启动成功之后,前往网页输入:http:192.168.190.148:3000(http://本机ip:3000)

Logo

汇聚全球AI编程工具,助力开发者即刻编程。

更多推荐