#无wget,请通过命令yuminstallwget安装 wgethttp://download.redis.io/releases/redis-3.0.1.tar.gztarxzfredis-3.0.1.tar.gz cdredis-3.0.1make#如果无make命令,请下载yuminstallgccmakemaketestmakeinstall
安装好了redis后,须注意拷贝bin文件到usr/local/bin(这步很重要,无这步会报错)
cpredis-server/usr/local/bin/cpredis-cli/usr/local/bin
daemonizeyes
编写启动shell:vim/etc/init.d/redis(copy网上的)
#chkconfig:23451090#description:StartandStopredis PATH=/usr/local/bin:/sbin:/usr/bin:/bin REDISPORT=6379#实际环境而定EXEC=/usr/local/redis/src/redis-server#实际环境而定REDIS_CLI=/usr/local/redis/src/redis-cli#实际环境而定 PIDFILE=/var/run/redis.pid CONF="/usr/local/redis/redis.conf"#实际环境而定 case"$1"in start)if[-f$PIDFILE]then echo"$PIDFILEexists,processisalreadyrunningorcrashed." else echo"StartingRedisserver..." $EXEC$CONF fi if["$?"="0"]then echo"Redisisrunning..." fi ;; stop)if[!-f$PIDFILE]then echo"$PIDFILEexists,processisnotrunning." else PID=$(cat$PIDFILE)echo"Stopping..." $REDIS_CLI-p$REDISPORTSHUTDOWNwhile[-x$PIDFILE]do echo"WaitingforRedistoshutdown..." sleep1 done echo"Redisstopped" fi ;; restart|force-reload)${0}stop${0}start ;; *)echo"Usage:/etc/init.d/redis{start|stop|restart|force-reload}">&2 exit1esac
赋予权限chmod+x /etc/init.d/redis
设置开机启动:
#尝试启动或停止redisserviceredisstartserviceredisstop #开启服务自启动chkconfigredison