redis自动化部署脚本

Redis版本自动化部署脚本


#!/bin/bash
#redis-版本
REDIS_VERSION="6.2.5"
#redis_文件地址
REDIS_ADDRESS="/usr/local/redisback"
#redis端口
REDIS_POST="10064"
#redsi脚本位置
REDIS_SET_ADDRESS="/usr/local/src/redis"

# 安装Redis相关依赖
yum install -y gcc make wget
# 下载Redis源码
wget http://download.redis.io/releases/redis-$REDIS_VERSION.tar.gz
# 解压Redis源码
tar -zxvf redis-$REDIS_VERSION.tar.gz
# 进入Redis源码目录
cd redis-$REDIS_VERSION
# 编译、安装Redis源
make && make install
#分配内存空间
echo "vm.overcommit_memory=1" >> /etc/sysctl.conf 

# 创建Redis目录
mkdir -p $REDIS_ADDRESS/{bin,conf}

#将Redis配置文件复制到Redis目录下
cp $REDIS_SET_ADDRESS/redis-$REDIS_VERSION/src/redis-server      $REDIS_ADDRESS/bin/
cp $REDIS_SET_ADDRESS/redis-$REDIS_VERSION/src/redis-cli         $REDIS_ADDRESS/bin/
cp $REDIS_SET_ADDRESS/redis-$REDIS_VERSION/src/redis-benchmark   $REDIS_ADDRESS/bin/
cp $REDIS_SET_ADDRESS/redis-$REDIS_VERSION/redis.conf            $REDIS_ADDRESS/conf/

#修改配置文件名称
mv $REDIS_ADDRESS/conf/redis.conf $REDIS_ADDRESS/conf/redis_$REDIS_POST.conf

#redis配置文件地址
REDIS_CONF_ADDRESS=$REDIS_ADDRESS/conf/redis_$REDIS_POST.conf

# 将Redisr日志配置设置
mkdir -p  $REDIS_ADDRESS/{run,logs,dbcache}

#设置redis端口
sed -i 's/port 6379/port '$REDIS_POST'/g'                                                  $REDIS_CONF_ADDRESS
#注释ip绑定
sed -i 's/bind 127.0.0.1/#bind 127.0.0.1/g'                                               $REDIS_CONF_ADDRESS
# 设置Redis为后台运行模式
sed -i 's/daemonize no/daemonize yes/g'                                                   $REDIS_CONF_ADDRESS
# redis保护模式调整
sed -i 's/protected-mode yes/daemonize no/g'                                              $REDIS_CONF_ADDRESS

#运行地址修改
#sed -i 's/pidfile /var/run/redis_6379.pid/pidfile /usr/local/redis/run/redis_6379.pid/g'  $REDIS_CONF_ADDRESS
#日志地址修改
#sed -i 's/logfile ""/logfile "/usr/local/redis/logs/redis_6379.log"/g'                    $REDIS_CONF_ADDRESS
#文件存储文档
#sed -i 's/dir .//dir /usr/local/redis/dbcache/g'                                          $REDIS_CONF_ADDRESS

# 设置Redis密码
sed -i 's/# requirepass foobared/requirepass taotao/g'                                    $REDIS_CONF_ADDRESS
# 设置Redis持久化
sed -i 's/# appendonly no/appendonly yes/g'                                               $REDIS_CONF_ADDRESS

# 启动Redis服务
$REDIS_ADDRESS/bin/redis-server  $REDIS_CONF_ADDRESS

你可能感兴趣的:(随笔,nginx,自动化,bootstrap)