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监控文档安装

相关内容

热门资讯

北京三位女大学生青海自驾游两死... 2024年7月,三位北京女大学生(小静、小田、小露)在青海省海西蒙古族藏族自治州德令哈市附近自驾游时...
德意燃气灶点着火后过几分钟熄火... 回答在:可能原因是熄火保护感应针故障、溢锅造成熄火、清洁炉头上的火盖未摆正,针对这几种问题,分别解决...
德意燃气灶打不着火什么原因 主要原因有,1、很大原因是电池没有电造成的。2、也有可能是由于点火针的位置不正,离内焰火盖距离比较远...
燃气热水器感应针是什么材质 燃气热水器燃烧室上面都有白色的磁棒,这是感应针。是热水器熄火保护最前端的一个部件,当火焰烧到感应针的...
燃气热水器感应针好坏判断 一般来说燃气热水器都有一个电板,当感应针出现故障的时候,都会显示相应的代码,通常感应针故障代码为E1...
热水器感应针位置 1、燃气热水器感应针的作用就是感应火焰是否正常燃烧,不燃烧时测量对地电阻大概在4M左右,当燃气燃烧时...
绿营利用台北鼠患制造恐慌,徐巧... 台北市近期爆发鼠患议题,引来绿营猛攻。中国国民党籍台北市长蒋万安5日召开记者会,宣布将派遣“鼠类侦防...
王世坚因称赞蒋万安被骂,蒋力挺... 据台湾联合新闻网、TVBS新闻网等台媒报道,民进党“立委”王世坚日前称赞台北市长蒋万安“心胸宽大、处...
全美汽油均价较伊朗战事前上涨5... 新华社北京5月7日电 美国汽车协会5日发布数据说,美国普通汽油当天平均零售价为每加仑4.48美元,较...
中国经济数据观丨十组数据看假日... 设计:穆问春文案:底东娜来源:交通运输部、商务部、文化和旅游部、公安部、国家移民管理局等