redis sentinel配置

來源:互聯網
上載者:User

標籤: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配置

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.