1、安装redis-exporter

  1. #1、下载redis-exporter
  2. cd /usr/local/src
  3. wget https://github.com/oliver006/redis_exporter/releases/download/v0.21.2/redis_exporter-v0.21.2.linux-amd64.tar.gz
  4. #2、解压redis-exporter
  5. tar xf redis_exporter-v0.21.2.linux-amd64.tar.gz
  6. #3、创建目录用于存放redis-exporter
  7. mkdir -p /usr/local/redis_exporter
  8. mv /usr/local/src/redis_exporter /usr/local/redis_exporter
  9. #4、把redis-exporter配成系统服务
  10. vi /etc/systemd/system/redis_exporter.service
  11. [Unit]
  12. Description=redis_exporter
  13. Documentation=redis_exporter
  14. [Service]
  15. ExecStart=/usr/local/redis_exporter/redis_exporter \
  16. --redis.addr 10.4.62.53:9003 #修改自己的redisIP地址以及对应的PORT
  17. [Install]
  18. WantedBy=multi-user.target
  19. #5、重新加载
  20. systemctl daemon-reload
  21. #6、把redis-exporter服务设置开机自启
  22. systemctl enable redis_exporter
  23. systemctl start redis_exporter
  24. #7、配置prometheus,添加以下代码:
  25. - job_name: 'redis_exporter'
  26. static_configs:
  27. - targets:
  28. - redis://10.4.62.33:9002 #对应的redis集群
  29. - redis://10.4.62.33:9005
  30. - redis://10.4.62.13:9001
  31. - redis://10.4.62.13:9004
  32. - redis://10.4.62.53:9003
  33. - redis://10.4.62.53:9006
  34. relabel_configs:
  35. - source_labels: [__address__]
  36. target_label: __param_target
  37. - source_labels: [__param_target]
  38. target_label: instance
  39. - target_label: __address__
  40. replacement: 10.4.62.33:9121 #配置一个即可,配置一个节点,这个节点会向后同步
  41. #8、重启prometheus
  42. systemctl restart prometheus

2、redis_exporter登录redis

无密码

  1. nohup ./redis_exporter -redis.addr 192.168.1.120:6379 &

有密码

  1. nohup ./redis_exporter -redis.addr 192.168.1.120:6379 -redis.password 123456
  2. #redis默认端口6379

3、Grafana展示redis_exporter

推荐使用763模板
image.png
image.png
image.png