码迷,mamicode.com
首页 > 其他好文 > 详细

redis sentinel配置

时间:2016-04-01 19:00:04      阅读:251      评论:0      收藏:0      [点我收藏+]

标签:redis sentinel

sentinel.conf

## --------------------------------------

port 26379


dir /tmp



# sentinel monitor <master-name> <ip> <redis-port> <quorum>

# master-name:不能包含特殊字符,自定义master名字

# ip: redis master IP

# redis-port: redis master PORT

# quorum: 客观DOWN至少多个sentinel同意

# Tells Sentinel to monitor this master, and to consider it in O_DOWN

# (Objectively Down) state only if at least <quorum> sentinels agree.

#

# Note that whatever is the ODOWN quorum, a Sentinel will require to

# be elected by the majority of the known Sentinels in order to

# start a failover, so no failover can be performed in minority.

#

# Slaves are auto-discovered, so you don‘t need to specify slaves in

# any way. Sentinel itself will rewrite this configuration file adding

# the slaves using additional configuration options.

# Also note that the configuration file is rewritten when a

# slave is promoted to master.

#

# Note: master name should not include special characters or spaces.

# The valid charset is A-z 0-9 and the three characters ".-_".

sentinel monitor mymaster 127.0.0.1 6379 2

sentinel auth-pass mymaster admin

sentinel down-after-milliseconds mymaster 30000

# sentinel parallel-syncs <master-name> <numslaves>

#

# How many slaves we can reconfigure to point to the new slave simultaneously

# during the failover. Use a low number if you use the slaves to serve query

# to avoid that all the slaves will be unreachable at about the same

# time while performing the synchronization with the master.

sentinel parallel-syncs mymaster 1

sentinel failover-timeout mymaster 180000


## ---------------------


sentinel启动脚本:

#!/bin/bash

#

# redis-sentinel - this script starts and stops the redis-sentinel daemon

#

# chkconfig:   - 80 12

# description:  Redis is a persistent key-value database

# processname: redis-server

# config:      /etc/redis/redis.conf

# pidfile:     /var/run/redis.pid

source /etc/init.d/functions

BIN="/usr/local/redis/bin"

CONFIG="/usr/local/redis/etc/sentinel.conf"

PIDFILE="/var/run/redis-sentinel.pid"

### Read configuration

[ -r "$SYSCONFIG" ] && source "$SYSCONFIG"

RETVAL=0

prog="redis-sentinel"

desc="Redis sentinel"

start() {

        if [ -e $PIDFILE ];then

             echo "$desc already running...."

             exit 1

        fi

        echo -n $"Starting $desc: "

        daemon $BIN/$prog $CONFIG --sentinel 2>&1 >> /var/log/messages &

        RETVAL=$?

        echo

        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog

        return $RETVAL

}

stop() {

        echo -n $"Stop $desc: "

        killproc $prog

        RETVAL=$?

        echo

        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog $PIDFILE

        return $RETVAL

}

restart() {

    stop

    start

}

case "$1" in

  start)

        start

        ;;

  stop)

        stop

        ;;

  restart)

        restart

        ;;

   *)

        echo $"Usage: $0 {start|stop|restart}"

        RETVAL=1

esac

exit $RETVAL


redis sentinel配置

标签:redis sentinel

原文地址:http://tianshili.blog.51cto.com/5050423/1759289

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!