首页 > 其他分享 >二进制部署 Prometheus

二进制部署 Prometheus

时间:2023-04-27 17:35:16浏览次数:39  
标签:2.37 amd64 二进制 prometheus xiaosun 部署 Prometheus linux root

二进制部署

Prometheus

(1)上传软件包

下载地址:

https://prometheus.io/download/

(2)解压软件包

mkdir /softwares -pv
tar xf prometheus-2.37.6.linux-amd64.tar.gz -C /softwares/

(3)启动prometheus Server

cd /softwares/prometheus-2.37.6.linux-amd64 
./prometheus 

启动脚本

cat > /etc/sysconfig/prometheus <<'EOF'
PROMETHEUS_HOME=/softwares/prometheus-2.37.6.linux-amd64
EOF


cat > /usr/lib/systemd/system/prometheus.service <<'EOF'
[Unit]
Description= prometheus server daemon
After=network.target

[Service]
EnvironmentFile=/etc/sysconfig/prometheus
ExecStart=/softwares/prometheus-2.37.6.linux-amd64/prometheus \
          --config.file=${PROMETHEUS_HOME}/prometheus.yml \
          --web.listen-address=0.0.0.0:9090 \
          --storage.tsdb.path=${PROMETHEUS_HOME}/data \
          --web.max-connections=10 \
          --storage.tsdb.retention.time=15d \
          --log.level=info \
          --web.read-timeout=5m
    
[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl start prometheus
systemctl status prometheus

(5)访问proemetheus Web UI

http://192.168.0.118:9090/

node-exporter

(1)上传软件包

(2)创建工作目录

mkdir /softwares -pv

(3)解压软件包

tar xf node_exporter-1.5.0.linux-amd64.tar.gz -C /softwares

启动脚本

cat > /usr/lib/systemd/system/node-exporter.service <<'EOF'
[Unit]
Description= Node exporter daemon
After=network.target

[Service]
ExecStart=/softwares/node_exporter-1.5.0.linux-amd64/node_exporter \
          --web.listen-address=:9100 \
          --log.level=info
          
    
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl restart node-exporter
systemctl status node-exporter

监控node expoeter节点:

1、修改二进制的prometheus server的配置文件监控node-exporter:

(1)修改配置文件

[root@xiaosun ~ ]# vim /softwares/prometheus-2.37.6.linux-amd64/prometheus.yml
scrape_configs:
  ...
  # 添加如下2个配置组即可。
  - job_name: "node_exporter_108"
    static_configs:
      - targets: ["192.168.0.118:9100"]

 

(2)重启服务

systemctl restart prometheus

2、prometheus 基于文件的方式动态发现节点并监控:

(1)修改配置文件

[root@xiaosun ~ ]#vim /softwares/prometheus-2.37.6.linux-amd64/prometheus.yml 
...
scrape_configs:
  ...
  - job_name: "node_exporter_file_sd"
    file_sd_configs:
    - files:
      - /softwares/prometheus-2.37.6.linux-amd64/config-file/node-exporter.yml
...
[root@xiaosun ~ ]#
[root@xiaosun ~ ]# systemctl restart prometheus.service 

(2)创建配置文件

[root@xiaosun prometheus-2.37.6.linux-amd64]# pwd
/xiaosun/softwares/prometheus-2.37.6.linux-amd64

[root@xiaosun prometheus-2.37.6.linux-amd64]# mkdir config-file
[root@xiaosun prometheus-2.37.6.linux-amd64]# 

[root@xiaosun prometheus-2.37.6.linux-amd64]# vim config-file/node-exporter.yml
[
  {
    "targets": ["10.0.0.109:19100","10.0.0.108:9100"]
  }
]
[root@xiaosun prometheus-2.37.6.linux-amd64]#

使用Grafana展示数据

1、安装grafana:

上传压缩包

yum -y localinstall grafana-enterprise-9.3.6-1.x86_64.rpm 

systemctl enable --now grafana-server.service 

二进制安装pushgateway组件:

上传pushgateway压缩包

(1)创建目录并解压软件包

mkdir /softwares -pv
tar xf pushgateway-1.5.1.linux-amd64.tar.gz -C /softwares/

(2)编写启动脚本

cat > /usr/lib/systemd/system/pushgateway.service <<'EOF'
[Unit]
Description=pushgateway daemon
After=network.target

[Service]
ExecStart=/softwares/pushgateway-1.5.1.linux-amd64/pushgateway \
          --web.listen-address=:9091 \
          --log.level=info
           
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl restart pushgateway
systemctl status pushgateway

二进制安装altermanager组件:

(1)创建工作目录

[root@xiaosun ~]# mkdir -pv /softwares

(2)解压altermanager

[root@xiaosun ~]# tar xf alertmanager-0.25.0.linux-amd64.tar.gz -C /softwares

(3)修改配置文件

[root@xiaosun alertmanager-0.25.0.linux-amd64]# cat alertmanager.yml 
global:
  resolve_timeout: 5m
  smtp_from: '[email protected]'
  smtp_smarthost: 'smtp.qq.com:465'
  smtp_auth_username: '[email protected]'
  smtp_auth_password: 'aicgtgsyfampbhia'
  smtp_require_tls: false
  smtp_hello: 'qq.com'
route:
  group_by: ['alertname']
  group_wait: 5s
  group_interval: 5s
  repeat_interval: 5m
  receiver: 'email'
receivers:
- name: 'email'
  email_configs:
  - to: '[email protected]'
    send_resolved: true
inhibit_rules:
  - source_match:
      severity: 'critical'
    target_match:
      severity: 'warning'
    equal: ['alertname', 'dev', 'instance']
[root@xiaosun alertmanager-0.25.0.linux-amd64]# 

(4)运行altermanager服务

[root@xiaosun alertmanager-0.25.0.linux-amd64]# ./alertmanager 

3、配置prometheus监控altermanager:

(1)修改altermanager的配置文件

[root@xiaosun prometheus-2.37.6.linux-amd64]# vim prometheus.yml 
...
alerting:
  alertmanagers:
    - static_configs:
        - targets:
            - 10.0.0.108:9093

rule_files:
    - "rule/rules.yml"

(2)编写prometheus的规则文件

[root@xiaosun prometheus-2.37.6.linux-amd64]# mkdir rule
[root@xiaosun prometheus-2.37.6.linux-amd64]# 
[root@xiaosun prometheus-2.37.6.linux-amd64]# vim rule/rules.yml
groups:
- name: container-runtime
  rules:
  - alert: container-10.0.0.108
    expr: up{instance="10.0.0.108:9100", job="node_exporter_108"} == 0
    for: 15s
    annotations:
      summary: "{{ $labels.instance }} 已停止运行超过 15s!"

  - alert: container-容器挂啦-2023
    expr: up{instance="10.0.0.109:9100", job="node_exporter_109"} == 0
    for: 5s
    annotations:
      summary: "Duang~ {{ $labels.instance }} 已停止运行超过 15s!"

(3)重启prometheus server服务

[root@xiaosun prometheus-2.37.6.linux-amd64]# systemctl restart prometheus

标签:2.37,amd64,二进制,prometheus,xiaosun,部署,Prometheus,linux,root
From: https://www.cnblogs.com/scfssq/p/17359538.html

相关文章

  • Cisco ISE 3.1部署教程
    网络拓扑图如下: Step1:ISE安装 选择"1"回车进入安装 ......
  • 关于将程序部署到服务器上
    这两天把程序迁移到天翼云服务器上,主要遇到了系统字符集排序规则的问题;把我思路整乱了。其实从无到有,最重要的是三步:1.软件安装。2.配置和数据。3.使用测试。软件安装1.确保IIS安装好了;把数据库软件安装好。2.把自己写的程序都复制到服务器上。配置和数据1.IIS中部署好网......
  • Prometheus+grafanaA
    一、Prometheus简介、容器监控的实现方对比虚拟机或者物理机来说比大的区别,比如容器在k8s环境中可以任意横向扩容与缩容,那么就需要监控服务能够自动对新创建的容器进行监控,当容器删除后又能够及时的从监控服务中删除,而传统的zabbix的监控方式需要在每一个容器中安装启动agent,并......
  • 微服务不是本地部署的最佳选择,不妨试试模块化单体
    微服务不能“包治百病”时下微服务是一个不错的架构,它具备模块化、可伸缩和高容错这些优点。许多公司都采用微服务架构并取得了巨大的成功,自然而然地,如果你正开始一个新项目,微服务似乎是最佳选择。然而,大多数采用微服务取得成功的公司并不是一开始就选择了这种架构。以Airbnb和Twit......
  • 【教程分享】一键部署MySQL,轻松搞定Docker安装和配置!
    1下载MySQL我们就可以到dockerhub来看:点击后的页面:直接执行dockerpullmysql,会下载最新版本的MySQL。点击tags,找到并下载经典的MySQL5.7:[root@service-monitoring~]#dockerpullmysql:5.7.42-oracle5.7.42-oracle:Pullingfromlibrary/mysqle83e8f2e82cc:Pull......
  • websphere6.1开发、部署、远程调用EJB2.0
    开发工具是IBMRAD7.5.4。WAS版本6.1。EJB版本2.0。开发过程如图:新建完后,工程结构如下:再新建SessionBean下一步完成。如图:修改几个文件:packagecom.ejb;importstaticjava.lang.System.out;/***BeanimplementationclassforEnterpriseBean:HelloSession*/publicc......
  • Redis部署与配置
    一、下载官网地址:https://redis.io/download/ 二、安装 三、配置——改端口,设置密码打开目录“C:\ProgramFiles\Redis”搜索“port”,更换端口搜索“requirepass”,设置密码重启服务 四、使用使用redis-studio连接redis Done. ......
  • blob实现在线预览二进制流pdf
    <iframeclass="prism-player"frameborder="0"scrolling="no":src="imgUrl+'#toolbar=0'"allowTransparency="true"></iframe>//如果要隐藏下载和打印按钮,在嵌入的地址后面加’#......
  • Nginx部署成Windows服务
    把nginx部署成服务,随系统开机启动,方法如下: 一、下载官网下载地址:http://nginx.org/en/download.html准备nginx-service 二、配置 三、安装服务 四、启动 Done. ......
  • Centos7部署docker
     一.安装前可以先开放443端口 firewall-cmd--zone=public--add-port=443/tcp--permanent1.正常使用yum安装yuminstall-ydocker-ce如果在过程中出现失败,解决办法1.yumcleanall2.yummakecache3.重新安装如果出现Couldn‘topenfile/mnt/repodata/repomd.x......