Install Redis Sentinel on CentOS6 Single Node

Introduction to Redis Sentinel Mode#

Redis-Sentinel is an officially recommended high-availability solution. When redis is doing a master-slave high-availability solution, if the master is down, redis itself (and many of its clients) have not realized automatic processing Active/standby switching, and redis-sentinel itself is also an independent process, which can be deployed in other machines that can communicate with the redis cluster to monitor the redis cluster

1、 From time to time, monitor whether redis is running as expected;
2、 If it is found that a redis node is running, it can notify another process (such as its client);
3、 Able to switch automatically. When a master node is not available, one of multiple slaves (if there is more than one slave) of the master can be elected as the new master, and the other slave nodes will change the address of the master it follows to be promoted to The new address of the master's slave.
4、 The sentry provides service discovery for the client. The client connects to the sentry. The sentry provides the address of the current master and then provides services. If there is a switch, that is, the master hangs up, the sentry will provide the client with a new address.

Redis Sentinel installation#

192.168.0.106 CentOS6.9

Install Redis

Reference: http://blog.csdn.net/wh211212/article/details/52817923

CentOS6 single node installation of Redis Sentinel

virsh attach-disk kvm-6 /dev/vg_shkvm3/kvm-6-data vdb –driver qemu –mode shareable

wget http://download.redis.io/releases/redis-3.2.8.tar.gz -P /usr/local/src
tar xvf redis-3.2.8.tar.gz -C /usr/local/
cd /usr/local/
ln -sv redis-3.2.8 redis
echo 512>/proc/sys/net/core/somaxconn
sysctl vm.overcommit_memory=1
yum groupinstall -y "Development Tools"
yum -y install tcl #Install tcl dependencies to prevent make test errors

Solution:
1 , Run make test with only single core:
taskset -c 1 sudo make test
2 , Change the tests/integration/replication-psync.tcl file:
vi tests/integration/replication-psync.tcl
Change the number after after in the code corresponding to the error from 100 to 500. I personally think that this parameter seems to be the number of milliseconds to wait.

cd redis && make && make test
mkdir -pv /data/redis-sentinel/{9000,9001,9002}
cp src/{redis-server,redis-sentinel}/data/redis-sentinel/9000/
cp src/{redis-server,redis-sentinel}/data/redis-sentinel/9001/
cp src/{redis-server,redis-sentinel}/data/redis-sentinel/9002/
cp redis.conf sentinel.conf /data/redis-sentinel/9000/
cp redis.conf sentinel.conf /data/redis-sentinel/9001/
cp redis.conf sentinel.conf /data/redis-sentinel/9002/
# vim /data/redis-sentinel/9000/redis.conf
bind 192.168.0.106protected-mode no
port 9000
daemonize yes
appendonly yes
# \ cp /data/redis-sentinel/9000/redis.conf /data/redis-sentinel/9001/redis.conf
# \ cp /data/redis-sentinel/9000/redis.conf /data/redis-sentinel/9002/redis.conf

sed -i 's/9000/9001/g'/data/redis-sentinel/9001/redis.conf
# vim /data/redis-sentinel/9001/redis.conf
port 9001
slaveof 192.168.0.1069000

# vim /data/redis-sentinel/9002/redis.conf
sed -i 's/9000/9002/g'/data/redis-sentinel/9002/redis.conf
port 9002
slaveof 192.168.0.1069000
# cd /data/redis-sentinel/9000/
# . /redis-server redis.conf

# cd ../9001/
# . /redis-server redis.conf

# cd ../9002/
# . /redis-server redis.conf

# ps -ef | grep redis
root      42181017:03?00:00:00./redis-server 192.168.0.106:9000
root      42381017:03?00:00:00./redis-server 192.168.0.106:9001
root      42521017:03?00:00:00./redis-server 192.168.0.106:9002
# /usr/local/redis/src/redis-cli -h 192.168.0.106-p 9000192.168.0.106:9000>set name aniu
OK
192.168.0.106:9000> get name
" aniu"192.168.0.106:9000> info replication
# Replication
192.168.0.106:9000> info replication
# Replication
role:master
connected_slaves:2
slave0:ip=192.168.0.106,port=9001,state=online,offset=1121,lag=0
slave1:ip=192.168.0.106,port=9002,state=online,offset=1121,lag=1
master_repl_offset:1121
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:2
repl_backlog_histlen:1120

Deploy sentinel

# cd /data/redis-sentinel/9000
# vim sentinel.conf
protected-mode no
port 29000
daemonize yes
dir /data/redis-sentinel/9000/logs
sentinel monitor mymaster 192.168.0.10690002
# mkdir logs
# . /redis-sentinel sentinel.conf

# \ cp sentinel.conf ../9001/
# \ cp sentinel.conf ../9002/
# cd ../9001/
port 29001
dir "/data/redis-sentinel/9001/logs"
# mkdir logs
# . /redis-sentinel sentinel.conf

- Deploy sentinel 3

# cd ../9002/
# vim sentinel.conf
port 29002
dir "/data/redis-sentinel/9002/logs"
# mkdir logs
# . /redis-sentinel sentinel.conf
# /usr/local/redis/src/redis-cli -h 192.168.0.106-p 29000[root@sh-kvm-3-69002]# /usr/local/redis/src/redis-cli -h 192.168.0.106-p 29000192.168.0.106:29000> sentinel masters
1)1)" name"2)"mymaster"3)"ip"4)"192.168.0.106"5)"port"6)"9000"7)"runid"8)"03427a4cd4f22401f55d07952424ba4b31144b57"9)"flags"10)"master"11)"link-pending-commands"12)"0"13)"link-refcount"14)"1"15)"last-ping-sent"16)"0"17)"last-ok-ping-reply"18)"542"19)"last-ping-reply"20)"542"21)"down-after-milliseconds"22)"30000"23)"info-refresh"24)"3335"25)"role-reported"26)"master"27)"role-reported-time"28)"515500"29)"config-epoch"30)"0"31)"num-slaves"32)"2"33)"num-other-sentinels"34)"0"35)"quorum"36)"2"37)"failover-timeout"38)"180000"39)"parallel-syncs"40)"1"192.168.0.106:29000> sentinel slaves mymaster
1)1)" name"2)"192.168.0.106:9002"3)"ip"4)"192.168.0.106"5)"port"6)"9002"7)"runid"8)"42ec153d250bf9aff05765346e0fdc2ee33d1257"9)"flags"10)"slave"11)"link-pending-commands"12)"0"13)"link-refcount"14)"1"15)"last-ping-sent"16)"0"17)"last-ok-ping-reply"18)"510"19)"last-ping-reply"20)"510"21)"down-after-milliseconds"22)"30000"23)"info-refresh"24)"6271"25)"role-reported"26)"slave"27)"role-reported-time"28)"548469"29)"master-link-down-time"30)"0"31)"master-link-status"32)"ok"33)"master-host"34)"192.168.0.106"35)"master-port"36)"9000"37)"slave-priority"38)"100"39)"slave-repl-offset"40)"57920"2)1)"name"2)"192.168.0.106:9001"3)"ip"4)"192.168.0.106"5)"port"6)"9001"7)"runid"8)"afdc283bae3f48fb0ceb6f8dd9af8248928406ec"9)"flags"10)"slave"11)"link-pending-commands"12)"0"13)"link-refcount"14)"1"15)"last-ping-sent"16)"0"17)"last-ok-ping-reply"18)"510"19)"last-ping-reply"20)"510"21)"down-after-milliseconds"22)"30000"23)"info-refresh"24)"6271"25)"role-reported"26)"slave"27)"role-reported-time"28)"548486"29)"master-link-down-time"30)"0"31)"master-link-status"32)"ok"33)"master-host"34)"192.168.0.106"35)"master-port"36)"9000"37)"slave-priority"38)"100"39)"slave-repl-offset"40)"57920"

Using sentry in jedis##

Redis common security settings##

requirepass yourpassword
rename-command FLUSHALL ""
rename-command FLUSHDB ""
rename-command KEYS ""

Recommended Posts

Install Redis Sentinel on CentOS6 Single Node
Install Docker on Centos7
Install Redis on Ubuntu
install LNMP on centos7.4
Install Java on Centos 7
Nodejs install on centos7
Install FFmpeg on CentOS 8
Install RabbitMQ on CentOS 7
Install Node.js on Centos
Maven install on centos7
Install MongoDB on CentOS 7
Install Surelog on CentOS8
Install redis5.0 in CentOS7
Openjdk install on centos7
Install Jenkins on centos7
CentOS 7 install Redis 5.0.8 original
install RabbitMQ on centos
Install RabbitMQ on CentOS 7
install Docker on centos6.5
install oracle on centos
Install Elasticsearch 6 on centos7
Install RabbitMQ on CentOS7
How to install and configure Redis on CentOS 8
Install mysql online on centos
Install ElasticSearch 7.x on CentOS 7
Linux Centos7 install redis tutorial
Install MySQL 8.0.16 on Linux Centos
Install docker transfer on Centos7
Install docker on Centos system
install EPEL repo on centos
CentOS 7 Redis 5.0.8 sentinel mode configuration
Install Zabbix 3.4 based on CentOS 7
install virtualbox on centos server
Install Nginx server on CentOS 7
How to install jdk1.8 on centOS7
How to install MySQL on CentOS 8
Install JDK8 in rpm on CentOS7
How to install Memcached on CentOS 8
Install MATE or XFCE on CentOS 7
How to install R on CentOS 8
How to install FFmpeg on CentOS 8
How to install Virtualbox on CentOS 8
How to install TensorFlow on CentOS 8
[Introduction to redis] Install redis under Centos
How to install TeamViewer on CentOS 8
How to install Perl 5 on CentOS
How to install Git on CentOS 8
How to install Gradle on CentOS 8
How to install Elasticsearch on CentOS 8
How to install Jenkins on CentOS 8
How to install Java on CentOS 8
How to install Go on CentOS 8
How to install GCC on CentOS 8
How to install Yarn on CentOS 8
How to install Nginx on CentOS 8
How to install Asterisk on CentOS 7
How to install Jenkins on CentOS 8
Install MySQL on Linux CentOS7 (Windows)
How to install Vagrant on CentOS 8
How to install Python 3.8 on CentOS 8
How to install Tomcat 9 on CentOS 8