Prometheus+ Grafana 监控系列---Prometheus 安装

环境:Cenots 7
版本:Prometheus 2.17

  1. 本文主要讲解如何安装Prometheus, 其简介等其它方面请自行查看官方信息:https://prometheus.io/
  2. 首先我们先准备好一台Linux Centos 7 ,配置好更新源与firewalld 防火墙功能
[root@Monitor-Server ~]# \cp -rf /usr/share/zoneinfo/Asia/Hong_Kong /etc/localtime
[root@Monitor-Server ~]# ntpdate hk.pool.ntp.org
[root@Monitor-Server ~]# clock -w
[root@Monitor-Server ~]# echo "*/5 * * * * /usr/sbin/ntpdate hk.pool.ntp.org >> /var/log/ntpdate.org" > /tmp/crontab.sys
[root@Monitor-Server ~]# crontab /tmp/crontab.sys && systemctl restart crond
[root@Monitor-Server ~]# yum -y install epel-release && yum clean all && yum makecache && yum -y update
  1. 下载安装Prometheus
[root@Monitor-Server ~]# wget https://github.com/prometheus/prometheus/releases/download/v2.17.1/prometheus-2.17.1.linux-amd64.tar.gz
[root@Monitor-Server ~]# tar xf prometheus-2.17.1.linux-amd64.tar.gz
[root@Monitor-Server ~]# mv prometheus-2.17.1.linux-amd64 /usr/local/prometheus
[root@Monitor-Server ~]# mkdir /usr/local/prometheus/{data,conf,logs,bin}
[root@Monitor-Server ~]# groupadd -g 106 -r prometheus && useradd -s /sbin/nologin -u 106 -r -g prometheus prometheus
[root@Monitor-Server ~]# cd /usr/local/prometheus/
[root@Monitor-Server ~]# mv prometheus promtool bin/ && mv prometheus.yml conf/ && chown -R prometheus:prometheus /usr/local/prometheus/
[root@Monitor-Server ~]# echo 'PATH=/usr/local/prometheus/bin:$PATH:$HOME/bin' >> /etc/profile && source /etc/profile
  1. 配置Prometheus 系统服务,注意:由于在安装时有配置安装与存放数据目录
[root@Monitor-Server ~]# more /lib/systemd/system/prometheus.service 
[Unit]
Description=Prometheus
Documentation=https://prometheus.io/
After=network.target

[Service]
Type=simple
User=prometheus
ExecStart=/usr/local/prometheus/bin/prometheus --config.file=/usr/local/prometheus/conf/prometheus.yml --storage.tsdb.path=/usr/local/prometheus/data --storage.tsdb.retention=90d
Restart=on-failure

[Install]
WantedBy=multi-user.target
[root@Monitor-Server ~]#
  1. 现在使用下面的systemctl命令重新加载systemd系统,并查看服务是否启动
[root@Monitor-Server ~]# systemctl daemon-reload
[root@Monitor-Server ~]# systemctl enable prometheus.service
[root@Monitor-Server ~]# systemctl start prometheus.service

在这里插入图片描述
6. 开放防火墙端口

[root@Monitor-Server ~]# firewall-cmd --zone=public --add-port=9090/tcp --permanent
[root@Monitor-Server ~]# firewall-cmd --reload
  1. 验证使用浏览器打开Prometheus Ui 监听页面
    在这里插入图片描述
    以上Prometheus 已安装完成,下一章开始安装node_exporters
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值