redis一键创建脚本

#!/bin/bash
redispwd=cy@123456
mkdir /application/tools  -p
cd /application/tools
wget http://download.redis.io/releases/redis-5.0.9.tar.gz
tar xzf redis-5.0.9.tar.gz
cd redis-5.0.9
yum install gcc gcc-c++  -y
make
cp   /application/tools/redis-5.0.9/src/redis-server   /application/tools/redis-5.0.9
cp   /application/tools/redis-5.0.9/src/redis-cli   /application/tools/redis-5.0.9
hostip=$(hostname -i)
sed -i "s#bind 127.0.0.1#bind ${hostip}#"  redis.conf
sed -i "s#daemonize no#daemonize yes#" redis.conf
sed -i "s#appendonly no#appendonly yes#" redis.conf
meminfo=$(cat  /proc/meminfo |grep MemTotal |awk -F ' ' '{print $2}')
redismaxmemory=$((${meminfo}*1024*9/10))


sed -i "567a maxmemory  ${redismaxmemory}" redis.conf

sed -i "509a  requirepass   ${redispwd}" redis.conf
nohup /application/tools/redis-5.0.9/redis-server  /application/tools/redis-5.0.9/redis.conf  &

  一键创建redis单机, 默认密码cy@123456

posted @ 2021-12-25 18:00  Cetus-Y  阅读(56)  评论(0编辑  收藏  举报