- To modify redis.conf, open the background run option:
# By default, Redis does not run as a daemon. Use ' yes ' if you need it.# Note that Redis would write a PID file in/var/run/redis.pid when daemonized.daemonize Yes
- Write a script that Vim/etc/init.d/redis:
# chkconfig:2345 90# Description:start and Stop redis path=/usr/local/bin:/sbin:/usr/bin:/bin redisport=6379 #实际环境而定E Xec=/usr/local/redis/src/redis-server #实际环境而定REDIS_CLI =/usr/local/redis/src/redis-cli #实际环境而定 pidfile=/var/run/ redis.pidconf= "/usr/local/redis/redis.conf" #实际环境而定 case "$" in start) if [-F $PIDFILE] Then echo "$PIDFILE exists, the process is already running or crashed." else echo "Starting Redis server ..." $EXEC $CONF fi If ["$?" = "0"] then echo "Redis is running ..." FI; STOP) if [!-F $PIDFILE] then echo ' $PIDFILE exists, process is not Running. " Else pid=$ (cat $PIDFILE) echo "Stopping ..." $REDIS _cl I-p $Redisport SHUTDOWN While [-X $PIDFILE] do E Cho "Waiting for Redis 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 1esac
- Execute permissions:
chmod +x/etc/init.d/redis
- Boot from:
# try to start or stop Redisservice Redis startservice redis Stop # Open service self-booting chkconfig Redis on
source:http://my.oschina.net/indestiny/blog/197272
CentOS Boot from Boot Redis