CentOS 6.5 install redis 3.0.7


1. 下载编译安装

wget http://download.redis.io/releases/redis-3.0.7.tar.gz
tar xzf redis-3.0.7.tar.gz
cd redis-3.0.7
make

     make 报错

    (1)  gcc not found

     解决方法

yum -y install gcc gcc-c++ autoconf make

 (2)

   解决方法

make MALLOC=libc

2. 安装并配置

make install
vi redis.conf

    修改redis.conf文件daemonize no改成yes

cp redis.conf /etc
cd /etc/init.d/    #编写redis服务启动和关闭脚本
vi redis

    

###########################
#chkconfig: 2345 10 90
#description: Start and Stop redis
PATH=/usr/local/bin:/sbin:/usr/bin:/bin
  
REDISPORT=6379
EXEC=/usr/local/bin/redis-server
REDIS_CLI=/usr/local/bin/redis-cli
  
PIDFILE=/var/run/redis.pid
CONF="/etc/redis.conf"
  
case "$1" in
   start)
       if [ -f $PIDFILE ]
       then
                echo "$PIDFILE exists,process is already running or crashed"
       else
                echo "Starting Redisserver..."
                $EXEC $CONF
       fi
       if [ "$?"="0" ]
       then
              echo "Redis isrunning..."
       fi
       ;;
   stop)
       if [ ! -f $PIDFILE ]
       then
                echo "$PIDFILE does notexist, process is not running"
       else
                PID=$(cat $PIDFILE)
                echo "Stopping ..."
                $REDIS_CLI -p $REDISPORTSHUTDOWN
                while [ -x ${PIDFILE} ]
               do
                    echo "Waiting forRedis to shutdown ..."
                    sleep 1
                done
                echo "Redis stopped"
        fi
       ;;
  restart|force-reload)
       ${0} stop
       ${0} start
       ;;
  *)
   echo "Usage: /etc/init.d/redis{start|stop|restart|force-reload}" >&2
       exit 1
esac
##############################

    

chmod +x redis     #添加可执行权限
chkconfig redis on #设置开机自动启动


启动服务

service redis start

关闭服务

service redis stop


你可能感兴趣的:(CentOS 6.5 install redis 3.0.7)