# 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
# 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
# cd /usr/redis # ./redis-server redis.conf
redis 127.0.0.1:6379> #显示此行意味着安装成功。
注意:默认的redis.conf文件参数是前台启动的,修改daemonize no为daemonize yes则为后台启动。
脚本的编码格式在window上编码放在linux可能不识别,可以用UltraEdit转换下格式“文件-->转换-->DOS 转 UNIX“
#!/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/redis.conf PIDFILE=/var/run/redis.pid DESC="redis daemon" SCRIPTNAME=/etc/rc.d/init.d/redis 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
把redis脚本文件放在 /etc/rc.d/init.d/ 目录下
# chmod +x /etc/rc.d/init.d/redis # chkconfig --add redis # chkconfig --level 345 redis on # chkconfig --list redis
原文地址:http://blog.csdn.net/sleeping_/article/details/39584065