prometheus+grafana监控文档安装
admin
2023-02-27 08:42:01
0

1.下载安装包
Wget https://github.com/prometheus/prometheus/releases/download/v2.10.0/prometheus-2.10.0.linux-amd64.tar.gz
2.创建运行用户
[root@localhost opt]# groupadd -r prometheus
[root@localhost opt]# useradd -r -g prometheus -d / -s /sbin/nologin -c "prometheus user" prometheus
3.二进制安装
[root@localhost opt]# tar -xf prometheus-2.10.0.linux-amd64.tar.gz
[root@localhost opt]# mkdir /etc/prometheus
[root@localhost opt]# mkdir /var/lib/prometheus
[root@localhost opt]# cp prometheus-2.10.0.linux-amd64/prometheus /usr/local/bin/
[root@localhost opt]# cp prometheus-2.10.0.linux-amd64/prometheus.yml /etc/prometheus/
[root@localhost opt]# chown -R prometheus:prometheus /etc/prometheus
[root@localhost opt]# chown -R prometheus:prometheus /var/lib/prometheus/
[root@localhost opt]# vim /usr/lib/systemd/system/prometheus.service

4.配置启动脚本
[Unit]
Description=prometheus
After=network.target
[Service]
Type=simple
User=prometheus
ExecStart=/usr/local/bin/prometheus \
--config.file=/etc/prometheus/prometheus.yml \
--storage.tsdb.path=/var/lib/prometheus \
--storage.tsdb.retention=15d \
--web.read-timeout=5m \
--web.max-connections=10 \
--query.max-concurrency=20 \
--query.timeout=2m \
--web.enable-lifecycle
Restart=on-failure
[Install]
WantedBy=multi-user.target
参数解释:
--config.file=/etc/prometheus/prometheus.yml ### prometheus配置文件
--storage.tsdb.path=/var/lib/prometheus ### prometheus 存储数据路径
--storage.tsdb.retention=15d ### prometheus采集数据保留时间
--web.read-timeout=5m ### 请求链接的最大等待时间          
--web.max-connections=10 ### 最大链接数
--query.max-concurrency=20 ### 最大支持的并发查询量
--query.timeout=2m ### 单个查询超时时间
--web.enable-lifecycle ### 热加载
5.启动
[root@localhost opt]# systemctl daemon-reload
[root@localhost opt]# systemctl enable prometheus
[root@localhost opt]# systemctl start prometheus
[root@localhost opt]# netstat -anlptu|grep :9090
tcp 0 0 127.0.0.1:58628 127.0.0.1:9090 ESTABLISHED 8528/prometheus
tcp6 0 0 :::9090 :::* LISTEN 8528/prometheus
tcp6 0 0 ::1:9090 ::1:58374 ESTABLISHED 8528/prometheus
tcp6 0 0 127.0.0.1:9090 127.0.0.1:58628 ESTABLISHED 8528/prometheus
tcp6 0 0 ::1:58374 ::1:9090 ESTABLISHED 8528/prometheus
prometheus+grafana监控文档安装
部署node_exporter
Node_exporter收集机器的系统数据,这里采用prometheus官方提供的exporter,除node_exporter外,官方还提供consul,memcached,haproxy,mysqld等exporter,具体可查看官网。

这里在prometheus服务和 node节点部署相关服务。
tar -zxvf node_exporter-0.17.0-rc.0.linux-amd64.tar.gz -C /usr/local/
cd /usr/local/
mv node_exporter-0.17.0-rc.0.linux-amd64 node_exporter
设置用户(节点)
groupadd prometheus
useradd -g prometheus -s /sbin/nologin prometheus
chown -R prometheus:prometheus /usr/local/node_exporter

[root@node1 ~]# vim /usr/lib/systemd/system/node_exporter.service
[Unit]
Description=node_exporter
Documentation=https://prometheus.io/
After=network.target
[Service]
Type=simple
User=prometheus
ExecStart=/usr/local/node_exporter/node_exporter
Restart=on-failure
[Install]
WantedBy=multi-user.target

[root@node1 ~]# systemctl enable node_exporter
[root@node1 ~]# systemctl start node_exporter

grafana安装
https://grafana.com/grafana/download
配置文件
配置文件位于/etc/grafana/grafana.ini,这里暂时保持默认配置即可
设置开机启动
systemctl enable grafana-server
systemctl start grafana-server
prometheus+grafana监控文档安装

相关内容

热门资讯

中央空调不制冷怎么办-中央空调... 中央空调,是电器股份有限公司主要产品之一,但是由于中央空调使用环境和使用方式的不同,在使用过程中就会...
空调不出水不制冷怎么回事 内罩长期不清洗,当然房间密封性差的话也会导致这种现象;其次就是外机问题,如果外机积满灰尘,会成空调制...
空调不出水,不制冷 原因有多种,可能是电源插头没有接牢、制冷剂不足、空调短时间休息间隙、空调滤网积灰等等。很多情况可以自...
中方反击了,欧盟回应 据凤凰卫视报道,中国商务部7月24日宣布对包括德国军工巨头莱茵金属公司在内的14家欧洲企业实施出口管...
这个“中国首次”,很有看点 刚刚,韩国釜山,第48届世界遗产大会传来好消息:“景德镇手工瓷业遗存”成功列入《世界遗产名录》!这是...
85岁剑桥教授,为何成了中国年... ·2026年6月,艾伦·麦克法兰在英国剑桥大学国王学院。(Muye.G/摄)(本文图片均由剑桥康河出...
西安造12英寸硅片月产销突破1... 12英寸电子级硅片是当前全球半导体产业链的紧缺关键材料。近日,记者从位于西安高新区的西安奕斯伟材料科...
把防人的墙筑太高,困住的可能是... 据新华社消息,近日OpenAI公司的两款大模型联合进行内部评估时失控,突破隔离测试环境,侵入了美国A...
三星Galaxy S27 Pr... IT之家 7 月 25 日消息,科技媒体 WinFuture 昨日(7 月 24 日)发布博文,分享...
郑丽文颁卢秀燕一等奖章,两人热... 中国国民党第22届第二次全代会25日上午登场,党主席郑丽文颁发实践一等奖章给即将卸任的党籍县市长,台...