Start redis on Centos and start redis on centos
- Modify redis. conf and enable the backend running options:
# By default Redis does not run as a daemon. Use 'yes' if you need it.# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.daemonize yes
- Compile the script, vim/etc/init. d/redis:
# Chkconfig: 2345 10 90 # description: Start and Stop redis 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 # The actual environment depends on PIDFILE =/var/run/redis. pidCONF = "/usr/local/redis. conf "# actual environment depends on case" $1 "in start) if [-f $ PIDFILE] then echo" $ PIDFILE exists, 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_CLI-p $ redisport shutdown while [-x $ PIDFILE] do echo" 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 1 esac
- Execution permission:
chmod +x /etc/init.d/redis
- Auto Start:
# Try to start or stop redisservice redis startservice redis stop # Start the chkconfig redis on
Source: http://my.oschina.net/indestiny/blog/197272
- Install reference http://www.cnblogs.com/silent2012/p/3499654.html