Redis boot script Centos6.5
1. Install Redis1 and download the source code. decompress the package and compile the source code.
# 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. Go to the src folder in the installation directory and copy the four executable files redis-server, redis-benchmark, redis-cli, and redis. conf to the same directory.
# 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. Start the Redis service.
# cd /usr/redis# ./redis-server redis.conf
4. Test the client.
Redis 127.0.0.1: 6379> # This line indicates that the installation is successful.
2: Set redis boot environment: Linux-Centos6.61. Write Startup Script
Note: The default redis. conf file parameter is enabled at the front end. If you change "daemonize no" to "daemonize yes", the system starts at the background.
The script encoding format in Windows may not be recognized in linux. You can use UltraEdit to convert the format "file --> Conversion --> DOS to UNIX".
#! /Bin/sh # chkconfig: 345 86 14 # description: startup and shutdown script for Redis PROGDIR =/usr/redis # installation path PROGNAME = redis-serverDAEMON = $ PROGDIR/$ PROGNAMECONFIG =/usr/redis. confPIDFILE =/var/run/redis. pidDESC = "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; esacexit 0
Put the redis script file in the/etc/rc. d/init. d/directory.
2. Add and start the service
# chmod +x /etc/rc.d/init.d/redis# chkconfig --add redis# chkconfig --level 345 redis on# chkconfig --list redis
3. Restart the test.