prometheus之redis_exporter部署

下载解压压缩包

复制代码
mkdir /opt/redis_exporter/
cd /opt/redis_exporter/
wget http://soft.download/soft/linux/prometheus/redis_exporter/redis_exporter-v1.50.0.linux-amd64.tar.gz
tar -zxvf redis_exporter-v1.50.0.linux-amd64.tar.gz
ln -s /opt/redis_exporter/redis_exporter-v1.50.0.linux-amd64/redis_exporter /usr/bin/

服务文件

复制代码
vim /etc/systemd/system/redis_exporter.service

[Service]
ExecStart=/usr/bin/redis_exporter -web.listen-address :9121 -redis.addr redis://127.0.0.1:6379 -redis.password qwer552434
[Install]
WantedBy=multi-user.target
[Unit]
Description=redis_exporter
After=network.target

设置开机自启并启动服务

复制代码
systemctl  daemon-reload
systemctl enable redis_exporter
systemctl start redis_exporter
systemctl status redis_exporter

防火墙放行端口

复制代码
firewall-cmd --permanent --add-port=9121/tcp --zone=public&&firewall-cmd --reload

安装脚本

复制代码
cat install_redis_exporter.sh

#!/bin/bash
InstallDir='/opt/redis_exporter/'
FileName='redis_exporter-v1.50.0.linux-amd64.tar.gz'

function RedFont(){
  echo -e "\033[31mError: $1 \033[0m"
}

function GreenFont(){
  echo -e "\033[32mSuccess: $1 \033[0m"
}

function YellowFont(){
  echo -e "\033[33mWarning: $1 \033[0m"
}

if [ ! -d "$InstallDir" ];then
    mkdir $InstallDir
else
    YellowFont "${InstallDir}文件夹已经存在,请删除后重新执行"
    exit
fi

#进入安装目录
cd $InstallDir

#下载安装包
wget http://soft.download/soft/linux/prometheus/redis_exporter/$FileName > /dev/null 2>&1

if [ $? -eq 0 ];then
   GreenFont "$FileName download success"
else
   RedFont "$FileName download faild"
   exit
fi

#解压安装包到指定目录,解压不包含压缩一级目录
tar -zxf $FileName --strip-components 1 -C $InstallDir > /dev/null 2>&1

if [ $? -eq 0 ];then
   GreenFont "$FileName decompress success"
else
   RedFont "$FileName decompress faild"
   exit
fi


#设置开机自启
cat > /etc/systemd/system/redis_exporter.service << EOF
[Service]
ExecStart=${InstallDir}redis_exporter -web.listen-address :9121 -redis.addr redis://127.0.0.1:6379 -redis.password qwer552434
[Install]
WantedBy=multi-user.target
[Unit]
Description=redis_exporter
After=network.target
EOF

#防火墙放行端口
firewall-cmd --permanent --add-port=9121/tcp --zone=public&&firewall-cmd --reload

#启动服务
systemctl  daemon-reload
systemctl enable redis_exporter
systemctl start redis_exporter && GreenFont "started redis_exporter" || RedFont "start redis_exporter faild"
相关推荐
9523613 小时前
Redis - 应用
数据库·redis·分布式·缓存
青山木13 小时前
一把 Redis 分布式锁,踩透四个坑:锁争抢、僵尸锁、锁过期、锁丢失
java·数据库·redis·后端
吴声子夜歌13 小时前
Redis 3.x——客户端
数据库·redis
衣乌安、13 小时前
Redis 分布式锁与任务状态
数据库·redis·分布式
微三云 - 廖会灵 (私域系统开发)16 小时前
电商系统监控告警体系从0到1:Prometheus+Grafana+AlertManager的全链路可观测性实践
oracle·grafana·prometheus
不能只会打代码17 小时前
Day 002 — Python 工程化 & FastAPI & 数据库速通
数据库·redis·python·docker·fastapi·测试
吴声子夜歌18 小时前
Redis 3.x——事务与Lua
redis·lua
江南风月19 小时前
WGCLOUD支持创建子账号吗
运维·zabbix·运维开发·prometheus
执笔论英雄21 小时前
【大模型推理】redis kv cache
数据库·redis·缓存
白露与泡影1 天前
Redis 缓存实战:雪崩、穿透、击穿一次讲透
数据库·redis·缓存