同服务器不同网站redis,同一台服务器,启动多个redis实例

#!/bin/sh

#chkconfig:2345 10 90#description: Startup and stop scriptforRedis

PATH=/usr/local/bin:/sbin:/usr/bin:/bin

REDISPORT_1=6379REDISPORT_2=6380REDISPORT_3=6381REDISPORT_4=6382REDISPORT_5=6383REDISPORT_6=6384REDISPORT_7=6385REDISPORT_8=6386REDISPORT_9=6387REDISPORT_10=6388REDISPORT_11=6389REDISPORT_12=6398REDISPORT_13=6399REDISPORTS=($REDISPORT_1 $REDISPORT_2 $REDISPORT_3 $REDISPORT_4 $REDISPORT_5 $REDISPORT_6 $REDISPORT_7 $REDISPORT_8 $REDISPORT_9 $REDISPORT_10 $REDISPORT_11 $REDISPORT_12 $REDISPORT_13)

EXEC=/usr/bin/redis-server

REDIS_CLI=/usr/bin/redis-cli

PIDFILE_1=/var/run/redis/redis_6379.pid

PIDFILE_2=/var/run/redis/redis_6380.pid

PIDFILE_3=/var/run/redis/redis_6381.pid

PIDFILE_4=/var/run/redis/redis_6382.pid

PIDFILE_5=/var/run/redis/redis_6383.pid

PIDFILE_6=/var/run/redis/redis_6384.pid

PIDFILE_7=/var/run/redis/redis_6385.pid

PIDFILE_8=/var/run/redis/redis_6386.pid

PIDFILE_9=/var/run/redis/redis_6387.pid

PIDFILE_10=/var/run/redis/redis_6388.pid

PIDFILE_11=/var/run/redis/redis_6389.pid

PIDFILE_12=/var/run/redis/redis_6398.pid

PIDFILE_13=/var/run/redis/redis_6399.pid

PIDFILES=($PIDFILE_1 $PIDFILE_2 $PIDFILE_3 $PIDFILE_4 $PIDFILE_5 $PIDFILE_6 $PIDFILE_7 $PIDFILE_8 $PIDFILE_9 $PIDFILE_10 $PIDFILE_11 $PIDFILE_12 $PIDFILE_13)

CONF_1=/etc/redis_6379.conf

CONF_2=/etc/redis_6380.conf

CONF_3=/etc/redis_6381.conf

CONF_4=/etc/redis_6382.conf

CONF_5=/etc/redis_6383.conf

CONF_6=/etc/redis_6384.conf

CONF_7=/etc/redis_6385.conf

CONF_8=/etc/redis_6386.conf

CONF_9=/etc/redis_6387.conf

CONF_10=/etc/redis_6388.conf

CONF_11=/etc/redis_6389.conf

CONF_12=/etc/redis_6398.conf

CONF_13=/etc/redis_6399.conf

CONFS=($CONF_1 $CONF_2 $CONF_3 $CONF_4 $CONF_5 $CONF_6 $CONF_7 $CONF_8 $CONF_9 $CONF_10 $CONF_11 $CONF_12 $CONF_13)

PASSWORD_1="liujiaqi"PASSWORD_2="luxingmin"PASSWORD_3="liujianmin"PASSWORD_4="fenglipeng"PASSWORD_5="limao"PASSWORD_6="xuchunhong"PASSWORD_7="huangxiongyi"PASSWORD_8="wangwenyu"PASSWORD_9="hezhiqiang"PASSWORD_10="7ujm8ik,"PASSWORD_11="7ujm8ik,"PASSWORD_12="7ujm8ik,"PASSWORD_13="7ujm8ik,"PASSWORDS=($PASSWORD_1 $PASSWORD_2 $PASSWORD_3 $PASSWORD_4 $PASSWORD_5 $PASSWORD_6 $PASSWORD_7 $PASSWORD_8 $PASSWORD_9 $PASSWORD_10 $PASSWORD_11 $PASSWORD_12 $PASSWORD_13)case "$1" instart)

i=0

for PID in${PIDFILES[@]}do

if [ -e $PID ]

then

echo"$PID has exist, process is running"

elseecho"$PID Start ..."$EXEC ${CONFS[i]}&fiif [ "$?" == "0"]

then

echo"$PID is running"

elseecho"$PID is failed to start"fi

let i++done

;;

stop)

i=0

for PID in${PIDFILES[@]}do

if [ ! -e $PID ]

then

echo"$PID does not exist, process is not running"

elseecho"$PID Stoping ..."$REDIS_CLI-a ${PASSWORDS[i]} -p ${REDISPORTS[i]} SHUTDOWN

sleep2

while [ -e $PID ]doecho"Waiting for Redis to shutdown ..."sleep1done

echo"$PID stopped"fi

let i++done

;;

restart)

${0} stop

${0} start

;;*)

echo"Usage: /etc/init.d/redis {start|stop|restart}" >&2exit1esac

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值