grafana修改服务器名字,Prometheus+grafana监控服务器及数据库实践笔记

本文介绍了如何使用Prometheus进行服务器和数据库监控,包括Prometheus的安装、配置,以及添加系统服务。同时,详细阐述了Grafana的安装过程,并提到了node_exporter和mysqld_exporter的安装与配置,用于收集服务器和MySQL的数据。最后,文章还提及了alertmanager的安装与配置,以实现告警通知。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Prometheus+grafana监控服务器及数据库实践笔记

Prometheus的安装

Prometheus安装脚本

vim setupprometheus.sh

#!/bin/bash

cd /opt

#下载

#wget https://github.com/prometheus/prometheus/releases/download/v2.19.2/prometheus-2.19.2.linux-amd64.tar.gz

#创建目录

mkdir /opt/prometheus

#解压

tar -zxf prometheus-2.19.2.linux-amd64.tar.gz -C /opt/prometheus --strip-components=1

#授权目录可执行

chown -R root:root /opt/prometheus

#启动

cd /opt/prometheus

nohup ./prometheus --config.file=prometheus.yml --storage.tsdb.retention=45d &

firewall-cmd --zone=public --add-port=9090/tcp --permanent

firewall-cmd --reload

#执行脚本完成安装;

./setupprometheus.sh

Prometheus添加系统服务脚本

vim /etc/systemd/system/prometheus.service

[Unit]

Description=Prometheus Server

Documentation=https://prometheus.io/docs/introduction/overview/

After=network.target

[Service]

Type=simple

User=root

Restart=on-failure

ExecStart=/opt/prometheus/prometheus --config.file=/opt/prometheus/prometheus.yml --storage.tsdb.path=/var/lib/prometheus

Restart=on-failure

[Install]

WantedBy=multi-user.target

Prometheus启动

#启动脚本授权可执行

chmod +x /etc/systemd/system/prometheus.service

#系统服务配置重新加载

systemctl daemon-reload

#服务添加可随机启动

systemctl enable prometheus.service

#启动服务

systemctl start prometheus.service

#查看服务状态

systemctl status prometheus.service

grafana-server的安装

vim setupgrafana.sh

#!/bin/bash

#下载

wget https://dl.grafana.com/oss/release/grafana-7.0.5-1.x86_64.rpm

#安装

yum localinstall grafana-7.0.5-1.x86_64.rpm

#启动

/etc/init.d/grafana-server start

firewall-cmd --zone=public --add-port=3000/tcp --permanent

firewall-cmd --reload

#写完要授权可执行

chmod +x setupgrafana.sh

#然后运行脚本安装

./setupgrafana.sh

node_exporter的安装

vim setupnode_export

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值