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"
相关推荐
一只游鱼11 分钟前
langchain4j+redis+持久化存储记忆
java·redis·langchain4j
亚空间仓鼠2 小时前
NoSQL数据库Redis(三):主从复制
redis·bootstrap·nosql
weisian1513 小时前
Java并发编程--33-Redis分布式缓存三大核心架构:主从、哨兵、分片,落地实战与选型
java·redis·缓存·主从架构·哨兵架构·分片架构
亚空间仓鼠4 小时前
NoSQL数据库Redis(四):哨兵集群
redis·bootstrap·nosql
我不听你讲话4 小时前
Redis 配置与优化核心内容总结
数据库·redis·缓存
Wy_编程4 小时前
redis 客户端编程
数据库·redis·缓存
熬夜的咕噜猫5 小时前
Nosql Redis配置与优化
数据库·redis·nosql
霸道流氓气质5 小时前
SpringBoot中集成LangChain4j+阿里百炼平台实现AI对话记忆功能、对话隔离、对话持久化到Redis功能
人工智能·spring boot·redis
givemeacar5 小时前
spring session、spring security和redis整合的简单使用
redis·spring·bootstrap
kiku18185 小时前
NoSQL之Redis配置与优化
数据库·redis·非关系型数据库