#!/bin/bash
#redis一键安装脚本
clear
redis=redis-3.0.3.tar.gz
installdir=/app
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 /app/redis/bin/ && mkdir /app/redis/etc/
cp redis.conf /app/redis/etc/
cp /usr/local/bin/redis* /app/redis/bin/
ln -s /app/redis/bin/redis* /usr/bin/
sed -i 's/daemonize no/daemonize yes/' /app/redis/etc/redis.conf
sed -i 's=pidfile /var/run/redis.pid=pidfile /app/redis/redis.pid=' /app/redis/etc/redis.conf
echo "启动redis"
/app/redis/bin/redis-server /app/redis/etc/redis.conf
echo "开放防火墙端口"
iptables -I INPUT -p tcp --dport 6379 -j ACCEPT
echo "设置开机启动"
echo "/app/redis/bin/redis-server /app/redis/etc/redis.conf" >> /etc/rc.local
echo "redis 已经安装完毕,端口6379,安装目录 /app/redis/"
运维QQ交流群:171586999
网友评论