redis官网下载自动安装脚本

注释:使用方法为 # ./redis.sh  version           ----version为官网版本号

#!/bin/bash
version=$1
serverurl='download.redis.io'
urlstatus=$(curl -s -m 5 -IL $serverurl|grep 200)
redis_home=/usr/local/redis
redis_log=/usr/local/redis/log
redis_dump=/usr/local/redis/dump
redis_conf=/usr/local/redis/etc
redis_pid=/usr/local/redis/run
redis_passwd=`date +%s |sha256sum |base64 |head -c 10 ;echo`
export PATH=$PATH:$redis_home/bin


if [ -z "$version" ]; then

echo "Please input version" && exit 1

fi

if [ "$urlstatus" == "" ];then

echo "urlstatus is OFF" && exit 1

fi

echo "Download redis from official website"

cd /usr/local/src
rm -rf redis-*.tar.gz
wget http://download.redis.io/releases/redis-"$version"'.tar.gz'
tar xzf redis-"$version"'.tar.gz'
cd redis-"$version"
make && make PREFIX="$redis_home" install

echo "ADD script and configuration file"

mkdir -p $redis_log $redis_conf $redis_dump $redis_pid
cd $redis_conf && touch redis.conf
cat /dev/null >redis.conf

echo "vm.overcommit_memory = 1" >> /etc/sysctl.conf && sysctl -p
echo "daemonize yes" >> redis.conf
echo "bind 0.0.0.0" >>redis.conf
echo "maxmemory 1024mb" >>redis.conf
echo "pidfile $redis_pid/redis.pid" >>redis.conf
echo "port 6379" >>redis.conf
echo "tcp-keepalive 0" >>redis.conf
echo "loglevel notice" >>redis.conf
echo "logfile "$redis_log"/redis.log" >>redis.conf
echo "databases 16" >>redis.conf
echo "rdbcompression yes" >>redis.conf
echo "dbfilename dump.rdb" >>redis.conf
echo "dir $redis_dump" >>redis.conf
echo "stop-writes-on-bgsave-error yes" >>redis.conf
echo "requirepass $redis_passwd" >>redis.conf
echo "save 60 1000" >>redis.conf
$redis_home/bin/redis-server $redis_conf/redis.conf
echo "Redis password is $redis_passwd"

转载于:https://www.cnblogs.com/xiaopaipai/p/10404591.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值