Prometheus部署

下载地址

https://prometheus.io/download/#prometheus

关闭防火墙

[root@prometheus ~]# systemctl stop firewalld
[root@prometheus ~]# setenforce 0

安装prometheus

[root@prometheus ~]# wegt https://github.com/prometheus/prometheus/releases/download/v2.28.0/prometheus-2.28.0.linux-amd64.tar.gz
[root@prometheus ~]# tar xf prometheus-2.28.0.linux-amd64.tar.gz

安装prometheus

[root@prometheus ~]# mv prometheus-2.28.0.linux-amd64 /usr/local/prometheus

[root@prometheus ~]# useradd -r -M -s /sbin/nologin prometheus

[root@prometheus ~]# mkdir -p /opt/data/prometheus

[root@prometheus ~]# chown -R prometheus.prometheus /usr/local/prometheus /opt/data/prometheus

[root@prometheus ~]# ll /usr/local/
total 0
drwxr-xr-x. 2 root       root         6 May 18  2020 bin
drwxr-xr-x. 2 root       root         6 May 18  2020 etc
drwxr-xr-x. 2 root       root         6 May 18  2020 games
drwxr-xr-x. 2 root       root         6 May 18  2020 include
drwxr-xr-x. 2 root       root         6 May 18  2020 lib
drwxr-xr-x. 3 root       root        17 Apr 23 05:53 lib64
drwxr-xr-x. 2 root       root         6 May 18  2020 libexec
drwxr-xr-x. 4 prometheus prometheus 132 Jun 21 12:01 prometheus
drwxr-xr-x. 2 root       root         6 May 18  2020 sbin
drwxr-xr-x. 5 root       root        49 Apr 23 05:53 share
drwxr-xr-x. 2 root       root         6 May 18  2020 src

[root@prometheus ~]# ll /opt/data/
total 0
drwxr-xr-x. 2 prometheus prometheus 6 Jun 28 08:31 prometheus

编写service文件

[root@prometheus ~]# vim /usr/lib/systemd/system/prometheus.service
[Unit]
Description=Prometheus
After=network.target

[Service]
Type=simple
Environment="GOMAXPROCS=4"
User=prometheus
Group=prometheus
ExecReload=/bin/kill -HUP $MAINPID
ExecStart=/usr/local/prometheus/prometheus \
  --config.file=/usr/local/prometheus/prometheus.yml \
  --storage.tsdb.path=/opt/data/prometheus \
  --storage.tsdb.retention=30d \
  --web.console.libraries=/usr/local/prometheus/console_libraries \
  --web.console.templates=/usr/local/prometheus/consoles \
  --web.listen-address=0.0.0.0:9090 \
  --web.read-timeout=5m \
  --web.max-connections=10 \
  --query.max-concurrency=20 \
  --query.timeout=2m \
  --web.enable-lifecycle
PrivateTmp=true
PrivateDevices=true
ProtectHome=true
NoNewPrivileges=true
LimitNOFILE=infinity
ReadWriteDirectories=/opt/data/prometheus
ProtectSystem=full

SyslogIdentifier=prometheus
Restart=always

[Install]
WantedBy=multi-user.target

启动prometheus

[root@prometheus ~]# systemctl daemon-reload   #重新加载服务的配置文件
[root@prometheus ~]# systemctl enable prometheus && systemctl start prometheus
[root@prometheus ~]# ss -antl
State         Recv-Q        Send-Q               Local Address:Port               Peer Address:Port       Process        
LISTEN        0             128                        0.0.0.0:22                      0.0.0.0:*                         
LISTEN        0             128                           [::]:22                         [::]:*                         
LISTEN        0             128                              *:9090      

AlertManager部署

下载AlertManager

[root@prometheus ~]# wget https://github.com/prometheus/alertmanager/releases/download/v0.22.2/alertmanager-0.22.2.linux-amd64.tar.gz
[root@prometheus ~]# tar xf alertmanager-0.22.2.linux-amd64.tar.gz

编写service文件

[root@prometheus ~]# vim /usr/lib/systemd/system/alertmanager.service
[Unit]
Description=Alertmanager
After=network.target

[Service]
Type=simple
User=prometheus
Group=prometheus
ExecStart=/usr/local/alertmanager/alertmanager \
  --config.file=/usr/local/alertmanager/alertmanager.yml \
  --storage.path=/usr/local/alertmanager/data \
  --web.listen-address=0.0.0.0:9093 \
  --cluster.listen-address=0.0.0.0:9094 \
  --log.level=info \
  --log.format=logfmt
Restart=always

[Install]
WantedBy=multi-user.target

启动AlertManager

[root@prometheus ~]# systemctl daemon-reload
[root@prometheus ~]# systemctl enable alertmanager && systemctl start alertmanager
[root@prometheus ~]# ss -antl
State         Recv-Q        Send-Q               Local Address:Port               Peer Address:Port       Process        
LISTEN        0             128                        0.0.0.0:22                      0.0.0.0:*                         
LISTEN        0             128                              *:9093                          *:*                         
LISTEN        0             128                              *:9094                          *:*                         
LISTEN        0             128                           [::]:22                         [::]:*                         
LISTEN        0             128                              *:9090   

配置prometheus

[root@prometheus ~]# vim /usr/local/prometheus/prometheus.yml
  - job_name: 'alertmanager'
    static_configs:
    - targets: ['192.168.137.132:9093']
[root@prometheus ~]# systemctl restart prometheus

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值