1、安装redis-exporter
#1、下载redis-exporter
cd /usr/local/src
wget https://github.com/oliver006/redis_exporter/releases/download/v0.21.2/redis_exporter-v0.21.2.linux-amd64.tar.gz
#2、解压redis-exporter
tar xf redis_exporter-v0.21.2.linux-amd64.tar.gz
#3、创建目录用于存放redis-exporter
mkdir -p /usr/local/redis_exporter
mv /usr/local/src/redis_exporter /usr/local/redis_exporter
#4、把redis-exporter配成系统服务
vi /etc/systemd/system/redis_exporter.service
[Unit]
Description=redis_exporter
Documentation=redis_exporter
[Service]
ExecStart=/usr/local/redis_exporter/redis_exporter \
--redis.addr 10.4.62.53:9003 #修改自己的redisIP地址以及对应的PORT
[Install]
WantedBy=multi-user.target
#5、重新加载
systemctl daemon-reload
#6、把redis-exporter服务设置开机自启
systemctl enable redis_exporter
systemctl start redis_exporter
#7、配置prometheus,添加以下代码:
- job_name: 'redis_exporter'
static_configs:
- targets:
- redis://10.4.62.33:9002 #对应的redis集群
- redis://10.4.62.33:9005
- redis://10.4.62.13:9001
- redis://10.4.62.13:9004
- redis://10.4.62.53:9003
- redis://10.4.62.53:9006
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 10.4.62.33:9121 #配置一个即可,配置一个节点,这个节点会向后同步
#8、重启prometheus
systemctl restart prometheus
2、redis_exporter登录redis
无密码
nohup ./redis_exporter -redis.addr 192.168.1.120:6379 &
有密码
nohup ./redis_exporter -redis.addr 192.168.1.120:6379 -redis.password 123456
#redis默认端口6379
3、Grafana展示redis_exporter
推荐使用763模板