Prometheus监控服务器

部署prometheus监控服务器

  1. 安装监控服务器
  2. 修改配置文件
  3. 编写service文件,管理服务
  4. 查看监控数据

所有主机系统均为CentOS7,提前配置IP、主机名、系统YUM源

安装监控软件(192.168.4.10主机操作)

安装软件

  1. [root@prometheus ~]# tar -xf prometheus_soft.tar.gz
  2. [root@prometheus ~]# cd prometheus_soft
  3. [root@prometheus prometheus_soft]# tar -xf prometheus-2.17.2.linux-386.tar.gz
  4. [root@prometheus prometheus_soft]# ls
  5. [root@prometheus prometheus_soft]# mv prometheus-2.17.2.linux-386 /usr/local/prometheus
  6. [root@prometheus prometheus_soft]# ls /usr/local/prometheus/

修改prometheus配置文件

  1. [root@prometheus ~]# vim /usr/local/prometheus/prometheus.yml
  2.      static_configs:
  3.      - targets: ['192.168.4.10:9090']    #修改最后一行,将IP地址改为本机IP
  4. [root@prometheus ~]# /usr/local/prometheus/promtool check config \
  5.      /usr/local/prometheus/prometheus.yml   #检查配置配置文件是否有语法错误

编写服务service文件,使用systemd管理服务

  1. [root@prometheus ~]# vim /usr/lib/systemd/system/prometheus.service
  2.      [Unit]
  3.      Description=Prometheus Monitoring System
  4.      After=network.target
  5.      [Service]
  6.      ExecStart=/usr/local/prometheus/prometheus \
  7.      --config.file=/usr/local/prometheus/prometheus.yml \
  8.      --storage.tsdb.path=/usr/local/prometheus/data/
  9.      [Install]
  10.      WantedBy=multi-user.target
  11. #--config.file和--storage.tsdb.path都是prometheus这个程序的参数
  12. #可以通过prometheus -h查看这个程序支持哪些参数
  13. #--config.file参数后面指定该程序使用哪个配置文件启动服务
  14. #--storage.tsdb.path参数后面指定该程序将数据存储在哪个目录下
  15.  
  16. [root@prometheus ~]# systemctl enable prometheus.service --now    #设置服务器开机自启动服务,并立刻启动该服务

设置防火墙、SELinux

  1. [root@prometheus ~]#firewall-cmd --set-default-zone=trusted
  2. [root@prometheus ~]#setenforce 0
  3. [root@prometheus ~]#sed -i '/SELINUX/s/enforcing/permissive/' /etc/selinux/con
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值