Redis Sentinel Configuration

Source: Internet
Author: User
Tags failover

Sentinel.conf

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

Port 26379


Dir/tmp



# Sentinel Monitor <master-name> <ip> <redis-port> <quorum>

# Master-name: cannot contain special characters, custom master name

# Ip:redis Master IP

# Redis-port:redis Master Port

# Quorum: Objective down at least multiple sentinel agree

# 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 would require to

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

# Start a failover, so no failover can is performed in minority.

#

# slaves is auto-discovered, so you don ' t need to specify slaves in

# any. Sentinel itself would rewrite this configuration file adding

# The slaves using additional configuration options.

# Also Note that the configuration file was 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 the new slave simultaneously

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

# to avoid this all the slaves would 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 Startup script:

#!/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 "$" in

Start

Start

;;

Stop

Stop

;;

Restart

Restart

;;

*)

echo $ "Usage: $ {Start|stop|restart}"

Retval=1

Esac

Exit $RETVAL


Redis Sentinel Configuration

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.