脚本安装redis

#!/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

 

转载于:https://www.cnblogs.com/ray-mmss/p/11154914.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值