首页 > 其他 > 详细

脚本安装redis

时间:2019-07-09 00:37:07      阅读:130      评论:0      收藏:0      [点我收藏+]
#!/bin/bash
read -p ‘input the version you want(like 5.0.5):‘ version
read -p ‘input redis password:‘ password
read -p ‘input local ip: ‘ ip
version=${version:-5.0.5}
password=${password:-"password"}
if [ ! "$ip" ];then
 echo ‘must input local ip !‘
 exit 1
fi
# version
VERSION=redis-$version
# download path
LOAD_PATH=/tmp
# install path
INSTALL_PATH=/apps/redis
if  [ ! -d $INSTALL_PATH ];then
 mkdir -p $INSTALL_PATH
fi
cd /tmp
# download source package
wget http://download.redis.io/releases/$VERSION.tar.gz
# decompression
tar -xf $VERSION.tar.gz
# compile and install
cd $VERSION
make && make install PREFIX=$INSTALL_PATH
cd $INSTALL_PATH
mkdir conf
cp /tmp/$VERSION/redis.conf  ./conf
#sed -i ‘s/logfile ""/logfile "access.log"/‘ conf/redis.conf
sed -i "s/# requirepass foobared/requirepass $password/" conf/redis.conf
sed -i ‘s/appendonly no/appendonly yes/‘ conf/redis.conf
sed -i ‘s/protected-mode no/protected-mode yes/‘ conf/redis.conf
sed -i "s/bind 127.0.0.1/bind 127.0.0.1 $ip/" conf/redis.conf
sed -i ‘s/daemonize no/daemonize yes/‘ conf/redis.conf
useradd redis
chown -R redis.redis $INSTALL_PATH
su  - redis
cd $INSTALL_PATH/bin
./redis-server ../conf/redis.conf

 

脚本安装redis

原文:https://www.cnblogs.com/ray-mmss/p/11154914.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!