资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

prometheus+grafana监控文档安装-创新互联

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

创新互联是一家专业提供鼓楼企业网站建设,专注与网站建设、成都网站制作、H5网站设计、小程序制作等业务。10年已为鼓楼众多企业、政府机构等服务。创新互联专业网站建设公司优惠进行中。

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

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


文章题目:prometheus+grafana监控文档安装-创新互联
本文来源:http://cdkjz.cn/article/ccgogp.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220