redis一键安装脚本

#!/bin/bash

#redis一键安装脚本

clear

redis=redis-3.0.3.tar.gz

installdir=/usr/local/redis

softdir=/opt/soft

if [ ! -d $softdir ];

then mkdir /opt/soft

fi

echo "下载软件包"

sleep 2

cd $softdir

wget http://download.redis.io/releases/redis-3.0.3.tar.gz

echo "安装依赖环境"

sleep 2

yum -y install tcl gcc-c++* make

#安装redis

echo "安装redis"

sleep 2

tar zxvf $redis && cd `echo $redis | awk -F".tar.gz" '{print $1}'`

make && make install

mkdir -p /usr/local/redis/bin/ && mkdir /usr/local/redis/etc/

cp redis.conf /usr/local/redis/etc/

cp /usr/local/bin/redis* /app/redis/bin/

ln -s /usr/local/redis/bin/redis* /usr/bin/

sed -i 's/daemonize no/daemonize yes/' /usr/local/redis/etc/redis.conf

sed -i 's=pidfile /var/run/redis.pid=pidfile /usr/local/redis/redis.pid=' /usr/local/redis/etc/redis.conf

echo "启动redis"

/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf

echo "开放防火墙端口"

iptables -I INPUT -p tcp --dport 6379 -j ACCEPT

echo "设置开机启动"

echo "/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf" >> /etc/rc.local

echo "redis 已经安装完毕,端口6379,安装目录 /app/redis/"




posted @ 2021-02-22 19:07  woaibaobei  阅读(182)  评论(0编辑  收藏  举报