1)安装redis服务
[root@localhost ~] yum -y install redis
[root@localhost ~] systemctl restart redis
2)配置redis
[root@localhost ~] redis-cli
#设置redis密码
127.0.0.1:6379> config set requirepass 123456
OK
3)安装redis_exporter
[root@localhost opt] ll redis_exporter-v1.6.1.linux-amd64.tar.gz
-rw-r--r--. 1 root root 3722984 May 18 05:26 redis_exporter-v1.6.1.linux-amd64.tar.gz
[root@localhost opt] tar -zxvf redis_exporter-v1.6.1.linux-amd64.tar.gz
[root@localhost opt] cp -r redis_exporter-v1.6.1.linux-amd64 /usr/local/redis_exporter
4)开启redis_exporter服务
[root@localhost ~] cd /usr/local/redis_exporter
[root@localhost redis_exporter] ./redis_exporter -redis.addr localhost:6379 -re
dis.password 123456
[root@localhost ~] netstat -tlunp|grep redis_exporte
tcp6 0 0 :::9121 :::* LISTEN 24471/redis_exporte
5)添加redis_exporter为系统服务开机启动配置文件redis_exporter.service
[root@localhost ~] vi /usr/lib/systemd/system/redis_exporter.service
[Unit]
Description=Prometheus Redis daemon
After=network.target
[Service]
Type=simple
Restart=always
ExecStart=/usr/local/redis_exporter/redis_exporter \
-redis.addr localhost:6379 \
-redis.password 123456
[Install]
WantedBy=multi-user.target
6)与prometheus集成
[root@localhost ~] vi /usr/local/prometheus/prometheus.yml
- job_name: 'redis_exporter'
scrape_interval: 10s
static_configs:
- targets: ['192.168.1.20:9121']
#添加一个job
[root@localhost ~] systemctl restart prometheus