prometheus监控redis、redis_cluster集群

1.1 安装下载redis_exporter

下载地址:
https://github.com/oliver006/redis_exporter/releases

tar -xvf  redis_exporter-v1.55.0.linux-amd64.tar.gz -C /usr/local/
cd /usr/local/
mv redis_exporter-v1.55.0.linux-amd64/ redis_exporter

1.2 启动

cd /usr/local/redis_exporter
nohup ./redis_exporter -redis.addr 172.20.2.18:6379 &    
nohup ./redis_exporter -redis.addr 172.20.2.18:6380 &   

多实例(有密码)
cd /usr/local/redis_exporter
nohup ./redis_exporter -redis.addr 172.2.1.3:6380 --redis.password=oj+xjlARRfJqbC+A --web.listen-address=:9120 &
nohup ./redis_exporter -redis.addr 172.2.1.3:6381 --redis.password=oj+xjlARRfJqbC+A --web.listen-address=:9121 &

1.3 配置systemctl并加入开机自启(此步骤可省略)

1.3.1 redis无密码版
cat > /etc/systemd/system/redis_exporter.service << "EOF"
[Unit]
Description=redis_exporter
After=local-fs.target network-online.target network.target
Wants=local-fs.target network-online.target network.target
 
[Service]
ExecStart=/usr/local/redis_exporter/redis_exporter -redis.addr 172.22.201.32:6380
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
1.3.2 redis有密码版
cat > /etc/systemd/system/redis_exporter.service << "EOF"
[Unit]
Description=redis_exporter
After=local-fs.target network-online.target network.target
Wants=local-fs.target network-online.target network.target
 
[Service]
ExecStart=/usr/local/bin/redis_exporter -redis.addr 172.22.201.32:6380 --redis.password=oj+xjlARRfJqbC+A --web.listen-address=:9120
ExecStart=/usr/local/bin/redis_exporter -redis.addr 172.22.201.32:6381 --redis.password=oj+xjlARRfJqbC+A --web.listen-address=:9121
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable redis_exporter
systemctl start redis_exporter
systemctl status redis_exporter

在这里插入图片描述

3.4配置prometheus

vim prometheus.yaml
#监控redis_cluster集群
  - job_name: 'redis_exporter_cluster'
    static_configs:
      - targets:
        - redis://172.22.1.4:6380
        - redis://172.22.1.4:6381
    params:
      check-keys: ["metrics:*"]
    metrics_path: /scrape
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: 172.22.15.84:9121
  #监控redis
  - job_name: 'redis_exporter'
    static_configs:
      - targets:
        - 172.22.15.84:9121

ps:replacement:redis_exporter所在机器的ip+端口

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值