需求:采用redis_exporter 收集数据,promethus采集redis_exporter数据,granfana展示数据
一、简易安装redis
yum install -y redisrpm -qa |grep redislsof -i :6379rpm -ql redissystemctl start redis
- 找到配置文件/etc/redis.conf,修改 requirepass QpMD61xo
- 重启动redis systemctl restart redis
二、下载redis_exporter 收集redis数据
wget https://github.com/oliver006/redis_exporter/releases/download/v1.4.0/redis_exporter-v1.4.0.linux-amd64.tar.gztar zxvf redis_exporter-v1.4.0.linux-amd64.tar.gzmv redis_exporter-v1.4.0.linux-amd64 /usr/local/exporter/redis_exportercd /usr/local/exporter/redis_exporter## 有密码nohup ./redis_exporter -redis.addr 127.0.0.1:6379 -redis.password QpMD61xo ## 无密码nohup ./redis_exporter -redis.addr 192.168.1.120:6379 &
[root@Prometheus redis_exporter]# tail -f nohup.out time="2020-02-22T12:26:24+08:00" level=info msg="Redis Metrics Exporter v1.4.0 build date: 2020-02-22-02:07:24 sha1: dde61ca2367f5fdb1f4a0c49022fcb0135715d22 Go: go1.13.8 GOOS: linux GOARCH: amd64"time="2020-02-22T12:26:24+08:00" level=info msg="Providing metrics at :9121/metrics"
- 查看redis_exporte是否开启 lsof -i:9121
三、配置promethus 采集数据
- 修改prometheus配置文件 vim /usr/local/prometheus/prometheus.yml
- job_name: 'redis' scrape_interval: 10s static_configs: - targets: ["114.67.116.119:9121"]
kill -hup `ps -ef |grep prometheus|grep -v grep|awk '{print $2}'`或者kill -9 PID/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml
四、granfna配置
- 配置prometheus数据源,添加prometheus插件,导入763模板 https://grafana.com/grafana/dashboards/763/revisions
注意 redis 添加密码后,一定要重启动redis服务,否则granfna获取不到数据。(折腾了半天没数据。。)