Redis教程

shell-Redis一键部署脚本

本文主要是介绍shell-Redis一键部署脚本,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

Redis一键部署

#!/bin/bash

systemctl stop firewalld
setenforce 0
echo -e "\033[36m安装环境已初始化!\033[0m"
[ -e /etc/redis/6379.conf ]
if [ $? -eq 0 ]
then
echo -e "\033[36m已安装Redis,退出安装!\033[0m"
exit
else
echo -e "\033[36m开始安装,请等待\033[0m"
fi

yum install -y gcc gcc-c++ make &>/dev/null
echo -e "\033[36m依赖包已安装完毕!\033[0m"

cd /opt
wget https://download.redis.io/releases/redis-5.0.7.tar.gz &>/dev/null
[ -e redis-5.0.7.tar.gz ]
if [ $? -eq 0 ]
then 
echo -e "\033[36m下载成功,等待解压\033[0m"
else
echo -e "\033[36m下载失败,检查网络等配置\033[0m"
exit
fi
tar zxf redis-5.0.7.tar.gz
cd redis-5.0.7/
make &>/dev/null
make PREFIX=/usr/local/redis install 
echo -e "\033[36m编译安装完成\033[0m"

cd utils/
./install_server.sh <<EOF




/usr/local/redis/bin/redis-server
EOF

ln -s /usr/local/redis/bin/* /usr/local/bin/
num=`ss -natp|grep 6379|wc -l`
if [ $num -ge 1 ]
then
echo -e "\033[36mredis 已启动\033[0m" 
else
echo -e "\033[36m启动失败,检查配置\033[0m"
fi

redis-cli
这篇关于shell-Redis一键部署脚本的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!