There are many ways to configure Redis to boot
But read the official script, or use the official (own shell level or self-knowledge ...)
1. Copy the script into the system directory
Cp/redis/utils/redis_init_script/etc/rc.d/init.d/redis
2. Modify the Script
Vim/etc/rc.d/init.d/redis
#!/bin/sh # # Simple Redis INIT.D script conceived to work on the Linux systems # as it does use of the/proc filesystem. redisport=6379 Exec=/usr/local/bin/redis-server cliexec=/usr/local/bin/redis-cli PIDFILE=/var/run/redis_${
Redisport}.pid conf= "/etc/redis/${redisport}.conf" case "$" in start) if [-f $PIDFILE] Then echo "$PIDFILE exists, process is already running or crashed" else echo "starting Redis
Server ... "$EXEC $CONF fi;;
STOP) if [!-F $PIDFILE] then echo ' $PIDFILE does not exist, process was not running " Else pid=$ (cat $PIDFILE) echo "Stopping ..." $CLIEXEC-P $REDISPORT s Hutdown while [-x/proc/${pid}] does echo "Waiting for Redis to Shutdo
WN ... "Sleep 1 done echo" Redis stopped fi;;
*) echo "Please use Start or stop as first argument";; Esac
1). In #!/bin/sh add #chkconfig:2345 80 90, (if not added, when registering the service: Service Redis does not chkconfig)
2). The Redisport configures
3 according to its own environment configuration. Exec=/usr/local/bin/redis-server changed to Exec=redis/src/redis-server
4) in its own environment. CLIEXEC=/USR/LOCAL/BIN/REDIS-CLI changed to CLIEXEC=REDIS/SRC/REDIS-CLI
5) in its own environment. Conf=/etc/redis/{redisport}.conf "changed to CONF=REDIS/REDIS.CONF &NBSP in its own environment;
6). Pidfile=/var/run/redis_{redisport}.conf "changed to own environment under conf=redis/redis.conf 6). Pidfile=/var/run/redis_{redisport}.pid changed to the configuration under its own environment (redis.conf: Pidfile/var/run/redis_6379.pid)
7). In $exec $ CONF followed by & $EXEC $CONF &
Modified file
#!/bin/sh #chkconfig: 2345 # # Simple Redis INIT.D script conceived to work in Linux systems # as it does use of the
/proc filesystem. redisport=6377 Exec=/home/software/redis/src/redis-server cliexec=/home/software/redis/src/redis-cli PIDFILE=/
Home/data/redis/run/redis.pid conf= "/home/software/redis/redis.conf" case "$" in start) if [-F $PIDFILE] Then echo "$PIDFILE exists, process is already running or crashed" else echo
"Starting Redis server ..." $EXEC $CONF & fi;;
STOP) if [!-F $PIDFILE] then echo ' $PIDFILE does not exist, process was not running " Else pid=$ (cat $PIDFILE) echo "Stopping ..." $CLIEXEC-P $REDISPORT s Hutdown while [-x/proc/${pid}] does echo "Waiting for Redis to Shutdo
WN ... "Sleep 1 Done echo "Redis stopped" FI;;
*) echo "Please use Start or stop as first argument";;
Esac
3. Registration service:
chkconfig--add Redis
[4]. Firewall configuration
Add configuration: Echo '-A input-m State--state new-m tcp-p TCP--dport 6 379-j ACCEPT ' >>/etc/sysconfig/iptables
Restart: service iptables restart
[5]. Start Services
Servicing Redis start [6]. Test
Reboot
Ps-ef | grep redis