prometheus 安装部署

prometheus 安装部署

Prometheus简介

Prometheus受启发于Google的Brogmon监控系统(相似的Kubernetes是从Google的Brog系统演变而来),从2012年开始由前Google工程师在Soundcloud以开源软件的形式进行研发,并且于2015年早期对外发布早期版本。2016年5月继Kubernetes之后成为第二个正式加入CNCF基金会的项目,同年6月正式发布1.0版本。2017年底发布了基于全新存储层的2.0版本,能更好地与容器平台、云平台配合。
Prometheus安装

Prometheus框架图

在这里插入图片描述

Pushgateway 组件下载

Pushgateway
prometheus-2.37.0-rc.0.linux-amd64.tar.gz
node_exporter
node_exporter-1.3.1.linux-amd64.tar.gz
pushgateway
pushgateway-1.4.3.linux-amd64.tar.gz

  • 解压软件至 /module
tar -zxcf pushgateway-1.4.3.linux-amd64.tar.gz -C /module/
tar -zxcf node_exporter-1.3.1.linux-amd64.tar.gz -C /module/
tar -zxcf pushgateway-1.4.3.linux-amd64.tar.gz -C /module/
  • xsync 节点文件分发
    开启4个Centos 7虚拟机
    添加/etc/hosts
192.168.0.100  ansible
192.168.0.102  rs1
192.168.0.104  rs2
192.168.0.105  rs4  proemthus #**服务器**

分发脚本

xsync /module/node_exporter-1.3.1/
xsync node_exporter.service

xsync 脚本

#!/bin/bash  
#1. 判断参数个数 
if [ $# -lt 1 ] 
then 
    echo Not Enough Arguement! 
    exit; 
fi
#2. 遍历集群所有机器 
for host in ansible rs1 rs2 
do
    echo ====================  $host  ==================== 
    #3. 遍历所有目录,挨个发送 
    for file in $@ 
    do 
        #4. 判断文件是否存在 
        if [ -e $file ] 
            then 
                #5. 获取父目录 
                pdir=$(cd -P $(dirname $file); pwd)
 
                #6. 获取当前文件的名称 
                fname=$(basename $file) 
                ssh $host "mkdir -p $pdir" 
                rsync -av $pdir/$fname $host:$pdir 
            else 
                echo $file does not exists! 
        fi 
    done 
done
  • 修改配置文件prometheus.yml
    注意格式代码对齐,冒号后有空格,可能启动不成功。
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
 - job_name: "prometheus"

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
      - targets: ["localhost:9090"]

 - job_name: 'pushgateway'
    static_configs:
      - targets: ['localhost:9091']
        labels:
          instance: pushgateway

 - job_name: 'node exporter'
    static_configs:
      - targets: [ 'localhost:9100', '192.168.0.100:9100', '192.168.0.102:9100' ]
  • 启动在prometheus目录下启动
    关闭firewalld setlinux 0
nohup ./prometheus -- config.file=prometheus.yml > ./prometheus.log 2>&1 &

http://192.168.0.105:9090/ 网页
在这里插入图片描述
ntpdate time3.aliyun.com 不同步报错
在这里插入图片描述

  • 开机启动node_exporter
    创建node_exporter.service
 /usr/lib/systemd/system/node_exporter.service
[Unit]
Description=node_exporter
Documentation=https://github.com/prometheus/node_exporter
After=network.target

[Service]
Type=simple
User=root
ExecStart=/module/node_exporter-1.3.1/node_exporter
Restart=on-failure

[Install]
WantedBy=multi-user.target

systemctl daemon-reload
systemctl enable node_exporter # 设置开机自启动
systemctl start node_exporter # 启动服务

  • pushgateway启动
nohup ./pushgateway --web.listen-address :9091 > ./pushgateway.log 2>&1 &
  • 打开 web 页面查看
    http://192.168.0.105:9090/

如有错误请指正

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值