Redis Multi-instance startup scripts

Source: Internet
Author: User
Tags stop script

1, modify redis.conf

Set up Redis background boot

Daemonize Yes


2, scripting

Vi/etc/init.d/redis

#!/bin/sh#chkconfig:2345 90#description:startup and stop script for redispath=/usr/local/bin:/sbin:/usr/bin:/ binredisport_1=6380redisport_2=6381redisport_3=6382redisport_4=6383redisport_5=6384redisport_6=6385redisports= ($REDISPORT _1 $REDISPORT _2 $REDISPORT _3 $REDISPORT _4 $REDISPORT _5 $REDISPORT _6) exec=/usr/local/redis/bin/redis-serverredis_cli=/usr/local/redis/bin/redis-clipidfile_1=/var/run/redis_6380. Pidpidfile_2=/var/run/redis_6381.pidpidfile_3=/var/run/redis_6382.pidpidfile_4=/var/run/redis_6383.pidpidfile_ 5=/var/run/redis_6384.pidpidfile_6=/var/run/redis_6385.pidpidfiles= ($PIDFILE _1 $PIDFILE _2 $PIDFILE _3 $PIDFILE _4 $ Pidfile_5 $PIDFILE _6) conf_1=/usr/local/redis/etc/redis_6380.confconf_2=/usr/local/redis/etc/redis_6381.confconf _3=/usr/local/redis/etc/redis_6382.confconf_4=/usr/local/redis/etc/redis_6383.confconf_5=/usr/local/redis/etc/ redis_6384.confconf_6=/usr/local/redis/etc/redis_6385.confconfs= ($CONF _1 $CONF _2 $CONF _3 $CONF _4 $CONF _5 $CONF _6) Case "$" in start) i=0 for PID in ${pidfiles[@]} do if [-e $PID] then echo                        "$PID have exist, process is running" else echo "$PID Start ..." $EXEC ${confs[i]} fi if ["$?" = = "0"] then Echo                "$PID is running" Else echo "$PID was failed to start" fi    Let i++ do;                        Stop) i=0 for PID in ${pidfiles[@]} do if [!-e $PID] Then echo "$PID does not exist, process was not running" else echo "$PID Stop                        ing ... "$REDIS _cli-p ${redisports[i]} SHUTDOWN sleep 2 While [-e $PID] do echo "Waiting for Redis to shutdown ... "Sleep 1 done echo" $PID stopped "   fi let i++ done;;  Restart) ${0} stop ${0} start; *) echo "Usage:/etc/init.d/redis {start|stop|restart}" >&2 exit 1esac
1,$1: The first argument to execute the command, such as/etc/init.d/redis Start,start is the first parameter
2,${0}: The path where the file is located, for example, the path to the file is/etc/init.d/redis, then the value of ${0} is the path
3, the script should be placed under/etc/init.d/, or the server Redis ... command will prompt you not to find Redis


3, add Execute permissions

chmod +x/etc/init.d/redis

Service Redis startservice redis stop<pre name= "code" class= "plain" >service redis restart

4, set boot start

Chkconfig Redis on
Chkconfig--add Redis




Redis Multi-instance startup scripts

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.