node_exporter+prometheus+grafana服务器监控
环境:centos7
思路:node_exporter插件收集服务器数据——prometheus存储插件收集的数据——grafana展示prometheus收集的数据
下载对应系统最新软件包prometheus和监控插件node_exporter
1、配置node_exporter成服务并修改端口
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | tar -zxvf node_exporter-1.0.1.linux-amd64. tar .gz cd node_exporter-1.0.1.linux-amd64 && cp node_exporter /usr/local/bin/ centos创建一个.service文件 cat << EOF > /usr/lib/systemd/system/node_exporter .service [Unit] Description=node_exporter After=network.target [Service] Type=simple User=root ExecStart= /usr/local/bin/node_exporter --web.listen-address=:19001 Restart=on-failure [Install] WantedBy=multi-user.target EOF 启动服务 systemctl daemon-reload systemctl start node_exporter && \ systemctl status node_exporter && \ systemctl enable node_exporter 验证:http: //ip :19001 /metrics |
2、prometheus安装配置成服务
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | cat << EOF > /usr/lib/systemd/system/prometheus .service [Unit] Description=Prometheus Documentation=https: //prometheus .io/ After=network.target [Service] Type=simple User=root ExecStart= /prometheus-2 .24.1.linux-amd64 /prometheus --config. file = /prometheus-2 .24.1.linux-amd64 /prometheus .yml --web. enable -lifecycle --storage.tsdb.retention=90d --web.listen-address=:19190 Restart=on-failure [Install] WantedBy=multi-user.target EOF 启动服务 systemctl daemon-reload systemctl start prometheus.service && \ systemctl status prometheus.service && \ systemctl enable prometheus.service 验证:http: //ip :19190 |
配置文件修改
1 2 3 4 5 6 7 8 9 10 11 | [root@node1 prometheus-2.24.1.linux-amd64] # cat prometheus.yml |grep -v '#' global: alerting: alertmanagers: - static_configs: - targets: rule_files: scrape_configs: - job_name: 'prometheus' static_configs: - targets: [ 'localhost:19001' ] |
3、grafana安装
1 2 3 4 5 6 | https: //www .cnblogs.com /imyalost/p/9873641 .html 参考 下载网址:https: //grafana .com /grafana/download/7 .3.7 wget https: //dl .grafana.com /oss/release/grafana-7 .3.7-1.x86_64.rpm sudo yum install grafana-7.3.7-1.x86_64.rpm 下载安装完成后,输入命令 systemctl start grafana-server 启动服务,打开浏览器,输入IP+端口,3000为Grafana的默认侦听端口。 系统默认用户名和密码为admin /admin ,第一次登陆系统会要求修改密码,修改密码后登陆,界面显示如下: |
4、grafana配置数据源prometheus,官网下载数据显示模板并导入,显示结果如下图所示:
做一个决定,并不难,难的是付诸行动,并且坚持到底。
分类:
监控
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)