首页 > 系统服务 > 详细

Linux安装Redis服务

时间:2016-03-28 12:05:37      阅读:222      评论:0      收藏:0      [点我收藏+]


tar xf /home/source/redis-3.0.6.tar.gz

cd redis-3.0.6

make PREFIX=/usr/local/redis install

mkdir /etc/redis

/bin/cp -f redis.conf /etc/redis/redis.conf

sed -i ‘s@^daemonize no@daemonize yes@‘    /etc/redis/redis.conf



redis服务脚本

#!/bin/sh

#

# chkconfig : 2345 45 90

# as it does use of the /proc filesystem.


REDISPORT=6379

EXEC=/usr/local/redis/bin/redis-server

CLIEXEC=/usr/local/redis/bin/redis-cli


PIDFILE=/var/run/redis.pid

CONF="/etc/redis/redis.conf"


start() {

        if [ -f $PIDFILE ]

        then

                echo "$PIDFILE exists, process is already running or crashed"

        else

                echo "Starting Redis server..."

                $EXEC $CONF

        fi

}


stop() {

        if [ ! -f $PIDFILE ]

        then

                echo "$PIDFILE does not exist, process is not running"

        else

                PID=$(cat $PIDFILE)

                echo "Stopping ..."

                $CLIEXEC -p $REDISPORT shutdown

                while [ -x /proc/${PID} ]

                do

                    echo "Waiting for Redis to shutdown ..."

                    sleep 1

                done

                echo "Redis stopped"

        fi

}


case "$1" in

    start)

        start

        ;;

    stop)

        stop

        ;;

    restart)

        stop

        start

        ;;

    *)

        echo "Please use start or stop as first argument"

        ;;

esac


启动redis

[root@iZ25jyqlmgdZ ~]# /etc/init.d/redis start

连接redis

[root@iZ25jyqlmgdZ ~]# /usr/local/redis/bin/redis-cli -h 127.0.0.1
127.0.0.1:6379>

获取redis中所有的key

127.0.0.1:6379> keys *







本文出自 “逢场做戏。” 博客,请务必保留此出处http://xiaofengmo.blog.51cto.com/10116365/1757451

Linux安装Redis服务

原文:http://xiaofengmo.blog.51cto.com/10116365/1757451

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!