Redis安装手册

wget http://download.redis.io/releases/redis-2.8.3.tar.gz
tar xzf redis-2.8.3.tar.gz
cd redis-2.8.3
make
2、编译完成后,在./Src目录下,有三个可执行文件redis-server、redis-benchmark、redis-cli和./redis.conf然后拷贝到一个目录下。
 
mkdir /usr/redis
cp redis-server  /usr/redis
cp redis-benchmark /usr/redis
cp redis-cli  /usr/redis
cp redis.conf  /usr/redis
cd /usr/redis
3、启动Redis服务。
 
redis-server   redis.conf
4、然后用客户端测试一下是否启动成功。
 
redis-cli
redis> set foo bar
OK
redis> get foo
"bar"
 
---------------------------------------------------------------------------------------------------------
然后自己动手制作一个redis启动脚本方便管理
1、vim /etc/rc.d/init.d/redisd
 
#!/bin/sh
#chkconfig: 345 86 14
#description: Startup and shutdown script for Redis
 
PROGDIR=/usr/redis #安装路径
PROGNAME=redis-server
DAEMON=$PROGDIR/$PROGNAME
CONFIG=/usr/redis.conf
PIDFILE=/var/run/redis.pid
DESC="redis daemon"
SCRIPTNAME=/etc/rc.d/init.d/redisd
 
start()
{
         if test -x $DAEMON
         then
        echo -e "Starting $DESC: $PROGNAME"
                   if $DAEMON $CONFIG
                   then
                            echo -e "OK"
                   else
                            echo -e "failed"
                   fi
         else
                   echo -e "Couldn't find Redis Server ($DAEMON)"
         fi
}
 
stop()
{
         if test -e $PIDFILE
         then
                   echo -e "Stopping $DESC: $PROGNAME"
                   if kill `cat $PIDFILE`
                   then
                            echo -e "OK"
                   else
                            echo -e "failed"
                   fi
         else
                   echo -e "No Redis Server ($DAEMON) running"
         fi
}
 
restart()
{
    echo -e "Restarting $DESC: $PROGNAME"
    stop
         start
}
 
list()
{
         ps aux | grep $PROGNAME
}
 
case $1 in
         start)
                   start
        ;;
         stop)
        stop
        ;;
         restart)
        restart
        ;;
         list)
        list
        ;;
 
         *)
        echo "Usage: $SCRIPTNAME {start|stop|restart|list}" >&2
        exit 1
        ;;
esac
exit 0
 
 
2、增加服务并开机启动
cp ./redisd /etc/rc.d/init.d/redisd
chmod +x /etc/rc.d/init.d/redisd
chkconfig --add redisd
chkconfig --level 345 redisd on
chkconfig --list redisd
执行该脚本后,就可以开始start|stop|restart|list你的服务了。
 
 
 
 
cp redis-server  /usr/local/redis
cp redis-benchmark /usr/local/redis
cp redis-cli  /usr/local/redis
cp redis.conf  /usr/local/redis
posted @ 2015-03-31 19:31  王立君  阅读(322)  评论(0编辑  收藏  举报