Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure redis Master-Slave switch by keepalived

2025-03-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the knowledge of "how to configure redis master-slave switch in keepalived". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

IP Planning:

Master node: 10.0.37.224

Backup node: 10.0.37.225

VIP:10.0.37.226

One 2 nodes install redis

1 installation

[root@ray0redis02 ~] # wget http://download.redis.io/releases/redis-4.0.9.tar.gz

[root@ray0redis02 ~] # tar xzf redis-4.0.9.tar.gz

[root@ray0redis02 ~] # cd redis-4.0.9

[root@ray0redis02 ~] # make

[root@ray0redis02 ~] # make install

[root@ray0redis02] # mkdir-p / usr/local/redis/bin

[root@ray0redis02] # mkdir-p / usr/local/redis/etc

[root@ray0redis02 ~] # cp redis.conf / usr/local/redis/etc

[root@ray0redis02 ~] # cd src/

[root@ray0redis02 ~] # cp mkreleasehdr.sh redis-benchmark redis-check-aof redis-cli redis-server / usr/local/redis/bin

# [root@ray0redis02 ~] $vi / usr/local/redis/etc/redis.conf # change the value of daemonize to yes

[root@ray0redis02] # sed-I 's/daemonize no/daemonize yes/g' / usr/local/redis/etc/redis.conf

# start

[root@ray0redis02] # / usr/local/redis/bin/redis-server / usr/local/redis/etc/redis.conf

2 configure slave information of backup node

[root@ray0redis02 ~] # grep "^ slaveof" / usr/local/redis/etc/redis.conf

Slaveof 10.0.37.224 6379

# start

[root@ray0redis02] # / usr/local/redis/bin/redis-server / usr/local/redis/etc/redis.conf

Second, install keepalived

1 both nodes use yum to install keepalived

[root@ray0redis01 ~] # yum-y install keepalived

[root@ray0redis02 ~] # yum-y install keepalived

2 Primary Node keepalived configuration File

[root@ray0redis01 ~] # cat / etc/keepalived/keepalived.conf

! Configuration File for keepalived

Global_defs {

Router_id redis01

}

Vrrp_script chk_redis

{

Script "/ etc/keepalived/scripts/redis_check.sh"

Interval 2

Timeout 2

Fall 3

}

Vrrp_instance redis {

State MASTER

Interface ens192 # # needs to be modified to the name of the actual network card

Virtual_router_id 60

Priority 100 # # weight, the larger the number, the greater the weight, and the value of the primary node is larger than that of the standby node.

Advert_int 1

Authentication {# all node must same

Auth_type PASS

Auth_pass 1111

}

Virtual_ipaddress {

10.0.37.226 # need to modify the virtual IP that is actually assigned

}

Track_script {

Chk_redis

}

Notify_master "/ etc/keepalived/scripts/redis_master.sh 127.0.0.1 10.0.37.225 6379" # 10.0.37.225 needs to be modified to the actual remote host IP

Notify_backup "/ etc/keepalived/scripts/redis_backup.sh 127.0.0.1 10.0.37.225 6379" # 10.0.37.225 needs to be modified to the actual remote host IP

Notify_fault / etc/keepalived/scripts/redis_fault.sh

Notify_stop / etc/keepalived/scripts/redis_stop.sh

}

3 standby node keepalived configuration file

[root@ray0redis02 ~] # cat / etc/keepalived/keepalived.conf

! Configuration File for keepalived

Global_defs {

Router_id redis02

}

Vrrp_script chk_redis

{

Script "/ etc/keepalived/scripts/redis_check.sh"

Interval 2

Timeout 2

Fall 3

}

Vrrp_instance redis {

State BACKUP

Interface ens192 # # needs to be modified to the name of the actual network card

Virtual_router_id 60

Priority 90

Advert_int 1

Authentication {# all node must same

Auth_type PASS

Auth_pass 1111

}

Virtual_ipaddress {

10.0.37.226 # need to modify the virtual IP that is actually assigned

}

Track_script {

Chk_redis

}

Notify_master "/ etc/keepalived/scripts/redis_master.sh 127.0.0.1 10.0.37.224 6379" # 10.0.37.224 needs to be modified to the actual remote host IP

Notify_backup "/ etc/keepalived/scripts/redis_backup.sh 127.0.0.1 10.0.37.224 6379" # 10.0.37.224 needs to be modified to the actual remote host IP

Notify_fault / etc/keepalived/scripts/redis_fault.sh

Notify_stop / etc/keepalived/scripts/redis_stop.sh

}

Virtual_server 10.0.37.226 6379 {

Delay_loop 6

Lb_algo rr

Lb_kind NAT

Nat_mask 255.255.255.0

Persistence_timeout 50

Protocol TCP

Sorry_server 127.0.0.1 80

Real_server 10.0.37.224 6379 {

Weight 1

TCP_CHECK {

Connect_timeout 3

Nb_get_retry 3

Delay_before_retry 3

Connect_port 6379

}

}

Real_server 10.0.37.225 6379 {

Weight 1

TCP_CHECK {

Connect_timeout 3

Nb_get_retry 3

Delay_before_retry 3

Connect_port 6379

}

}

}

4 all scripts for two nodes

[root@ray0redis01 ~] # cat / etc/keepalived/scripts/redis_check.sh

#! / bin/bash

ALIVE= `/ usr/local/redis/bin/redis-cli-a 123456 PING`

["$ALIVE" = = "PONG"] & & {echo $ALIVE & & exit 0;} | {echo $ALIVE & & exit 1;}

[root@ray0redis01 ~] # cat / etc/keepalived/scripts/redis_master.sh

#! / bin/bash

REDISCLI= "/ usr/local/redis/bin/redis-cli-h $1-p $3"

LOGFILE= "/ var/log/keepalived-redis-state.log"

Echo "[master]" > > $LOGFILE

Date > > $LOGFILE

Echo "Being master...." > > $LOGFILE

Echo "Run MASTER cmd..." > > $LOGFILE

$REDISCLI SLAVEOF $2 $3 > $LOGFILE

Sleep 10 # delay 10 s wait data async cancel sync

Echo "Run SLAVEOF NO ONE cmd..." > > $LOGFILE

${REDISCLI} SLAVEOF NO ONE > > $LOGFILE

[root@ray0redis01 ~] # cat / etc/keepalived/scripts/redis_backup.sh

#! / bin/bash

REDISCLI= "/ usr/local/redis/bin/redis-cli-h $1-p $3"

LOGFILE= "/ var/log/keepalived-redis-state.log"

Echo "[backup]" > > $LOGFILE

Date > > $LOGFILE

Echo "Run SLAVEOF cmd..." > > $LOGFILE

$REDISCLI SLAVEOF $2 $3 > > $LOGFILE 2 > & 1

Sleep 15 # delay 15 s wait data sync exchange role

[root@ray0redis01 ~] # cat / etc/keepalived/scripts/redis_fault.sh

#! / bin/bash

LOGFILE=/var/log/keepalived-redis-state.log

Echo-e "[fault]\ t $(date'+% F% T')" > > $LOGFILE

[root@ray0redis01 ~] # cat / etc/keepalived/scripts/redis_stop.sh

#! / bin/bash

LOGFILE=/var/log/keepalived-redis-state.log

Start keepalived, verify the condition of HA and switch

[root@ray0redis01 ~] # systemctl status keepalived

● keepalived.service-LVS and VRRP High Availability Monitor

Loaded: loaded (/ usr/lib/systemd/system/keepalived.service; disabled; vendor preset: disabled)

Active: active (running) since Mon 2018-12-03 20:41:42 EST; 1h 10min ago

Process: 5122 ExecStart=/usr/sbin/keepalived $KEEPALIVED_OPTIONS (code=exited, status=0/SUCCESS)

Main PID: 5124 (keepalived)

CGroup: / system.slice/keepalived.service

├─ 5124 / usr/sbin/keepalived-D

├─ 5125 / usr/sbin/keepalived-D

└─ 5126 / usr/sbin/keepalived-D

Dec 03 20:57:08 ray0redis01 Keepalived_vrrp [5126]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 03 20:57:08 ray0redis01 Keepalived_vrrp [5126]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 03 20:57:08 ray0redis01 Keepalived_vrrp [5126]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 03 20:57:08 ray0redis01 Keepalived_vrrp [5126]: Opening script file / etc/keepalived/scripts/redis_master.sh

Dec 03 20:57:13 ray0redis01 Keepalived_vrrp [5126]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 03 20:57:13 ray0redis01 Keepalived_vrrp [5126]: VRRP_Instance (redis) Sending/queueing gratuitous ARPs on ens192 for 10.0.37.226

Dec 03 20:57:13 ray0redis01 Keepalived_vrrp [5126]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 03 20:57:13 ray0redis01 Keepalived_vrrp [5126]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 03 20:57:13 ray0redis01 Keepalived_vrrp [5126]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 03 20:57:13 ray0redis01 Keepalived_vrrp [5126]: Sending gratuitous ARP on ens192 for 10.0.37.226

[root@ray0redis01 ~] # / usr/local/redis/bin/redis-cli info | egrep-A11 Replication

# Replication

Role:master

Connected_slaves:1

Slave0:ip=10.0.37.225,port=6379,state=online,offset=4928,lag=1

Master_replid:ac8db2b7075f51c318b978be0a350b7fd987ddbb

Master_replid2:3e93b153857adbdfa981a3f66fd18244b9bfae5c

Master_repl_offset:4928

Second_repl_offset:183

Repl_backlog_active:1

Repl_backlog_size:1048576

Repl_backlog_first_byte_offset:183

Repl_backlog_histlen:4746

# Kill the redis process

[root@ray0redis01] # kill-9 6605

[root@ray0redis01 ~] # systemctl status keepalived

● keepalived.service-LVS and VRRP High Availability Monitor

Loaded: loaded (/ usr/lib/systemd/system/keepalived.service; disabled; vendor preset: disabled)

Active: active (running) since Mon 2018-12-03 20:41:42 EST; 1h 12min ago

Process: 5122 ExecStart=/usr/sbin/keepalived $KEEPALIVED_OPTIONS (code=exited, status=0/SUCCESS)

Main PID: 5124 (keepalived)

CGroup: / system.slice/keepalived.service

├─ 5124 / usr/sbin/keepalived-D

├─ 5125 / usr/sbin/keepalived-D

└─ 5126 / usr/sbin/keepalived-D

Dec 03 20:57:08 ray0redis01 Keepalived_vrrp [5126]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 03 20:57:08 ray0redis01 Keepalived_vrrp [5126]: Opening script file / etc/keepalived/scripts/redis_master.sh

Dec 03 20:57:13 ray0redis01 Keepalived_vrrp [5126]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 03 20:57:13 ray0redis01 Keepalived_vrrp [5126]: VRRP_Instance (redis) Sending/queueing gratuitous ARPs on ens192 for 10.0.37.226

Dec 03 20:57:13 ray0redis01 Keepalived_vrrp [5126]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 03 20:57:13 ray0redis01 Keepalived_vrrp [5126]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 03 20:57:13 ray0redis01 Keepalived_vrrp [5126]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 03 20:57:13 ray0redis01 Keepalived_vrrp [5126]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 03 21:54:33 ray0redis01 Keepalived_vrrp [5126]: / etc/keepalived/scripts/redis_check.sh exited with status 1

Dec 03 21:54:34 ray0redis01 Keepalived_healthcheckers [5125]: TCP connection to [10.0.37.224]: 6379 failed.

# observe the status of the slave node and complete the switch

[root@ray0redis02 ~] # systemctl status keepalived

● keepalived.service-LVS and VRRP High Availability Monitor

Loaded: loaded (/ usr/lib/systemd/system/keepalived.service; disabled; vendor preset: disabled)

Active: active (running) since Mon 2018-12-03 20:54:37 EST; 1h 0min ago

Process: 6112 ExecStart=/usr/sbin/keepalived $KEEPALIVED_OPTIONS (code=exited, status=0/SUCCESS)

Main PID: 6114 (keepalived)

CGroup: / system.slice/keepalived.service

├─ 6114 / usr/sbin/keepalived-D

├─ 6115 / usr/sbin/keepalived-D

└─ 6116 / usr/sbin/keepalived-D

Dec 03 21:54:39 ray0redis02 Keepalived_vrrp [6116]: Opening script file / etc/keepalived/scripts/redis_master.sh

Dec 03 21:54:41 ray0redis02 Keepalived_healthcheckers [6115]: TCP connection to [10.0.37.224]: 6379 failed.

Dec 03 21:54:41 ray0redis02 Keepalived_healthcheckers [6115]: Check on service [10.0.37.224]: 6379 failed after 1 retry.

Dec 03 21:54:41 ray0redis02 Keepalived_healthcheckers [6115]: Removing service [10.0.37.224]: 6379 from VS [10.0.37.226]: 6379

Dec 03 21:54:44 ray0redis02 Keepalived_vrrp [6116]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 03 21:54:44 ray0redis02 Keepalived_vrrp [6116]: VRRP_Instance (redis) Sending/queueing gratuitous ARPs on ens192 for 10.0.37.226

Dec 03 21:54:44 ray0redis02 Keepalived_vrrp [6116]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 03 21:54:44 ray0redis02 Keepalived_vrrp [6116]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 03 21:54:44 ray0redis02 Keepalived_vrrp [6116]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 03 21:54:44 ray0redis02 Keepalived_vrrp [6116]: Sending gratuitous ARP on ens192 for 10.0.37.226

[root@ray0redis02] # tail-20f / var/log/messages

Dec 3 21:54:38 localhost Keepalived_healthcheckers [6115]: TCP connection to [10.0.37.224]: 6379 failed.

Dec 3 21:54:38 localhost Keepalived_vrrp [6116]: VRRP_Instance (redis) Transition to MASTER STATE

Dec 3 21:54:39 localhost Keepalived_vrrp [6116]: VRRP_Instance (redis) Entering MASTER STATE

Dec 3 21:54:39 localhost Keepalived_vrrp [6116]: VRRP_Instance (redis) setting protocol VIPs.

Dec 3 21:54:39 localhost Keepalived_vrrp [6116]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 3 21:54:39 localhost Keepalived_vrrp [6116]: VRRP_Instance (redis) Sending/queueing gratuitous ARPs on ens192 for 10.0.37.226

Dec 3 21:54:39 localhost Keepalived_vrrp [6116]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 3 21:54:39 localhost Keepalived_vrrp [6116]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 3 21:54:39 localhost Keepalived_vrrp [6116]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 3 21:54:39 localhost Keepalived_vrrp [6116]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 3 21:54:39 localhost NetworkManager: [1543892079.9698] policy: set-hostname: current hostname was changed outside NetworkManager: 'ray0redis02'

Dec 3 21:54:41 localhost Keepalived_healthcheckers [6115]: TCP connection to [10.0.37.224]: 6379 failed.

Dec 3 21:54:41 localhost Keepalived_healthcheckers [6115]: Check on service [10.0.37.224]: 6379 failed after 1 retry.

Dec 3 21:54:41 localhost Keepalived_healthcheckers [6115]: Removing service [10.0.37.224]: 6379 from VS [10.0.37.226]: 6379

Dec 3 21:54:44 localhost Keepalived_vrrp [6116]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 3 21:54:44 localhost Keepalived_vrrp [6116]: VRRP_Instance (redis) Sending/queueing gratuitous ARPs on ens192 for 10.0.37.226

Dec 3 21:54:44 localhost Keepalived_vrrp [6116]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 3 21:54:44 localhost Keepalived_vrrp [6116]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 3 21:54:44 localhost Keepalived_vrrp [6116]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 3 21:54:44 localhost Keepalived_vrrp [6116]: Sending gratuitous ARP on ens192 for 10.0.37.226

# start the master node, and switch keepalived and redis back to the master node

[root@ray0redis01] # / usr/local/redis/bin/redis-server / usr/local/redis/etc/redis.conf

12049:C 03 Dec 21:56:37.698 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo

12049:C 03 Dec 21:56:37.698 # Redis version=4.0.9, bits=64, commit=00000000, modified=0, pid=12049, just started

12049:C 03 Dec 21:56:37.698 # Configuration loaded

[root@ray0redis01 ~] # systemctl status keepalived

● keepalived.service-LVS and VRRP High Availability Monitor

Loaded: loaded (/ usr/lib/systemd/system/keepalived.service; disabled; vendor preset: disabled)

Active: active (running) since Mon 2018-12-03 20:41:42 EST; 1h 14min ago

Process: 5122 ExecStart=/usr/sbin/keepalived $KEEPALIVED_OPTIONS (code=exited, status=0/SUCCESS)

Main PID: 5124 (keepalived)

CGroup: / system.slice/keepalived.service

├─ 5124 / usr/sbin/keepalived-D

├─ 5125 / usr/sbin/keepalived-D

├─ 5126 / usr/sbin/keepalived-D

├─ 12057 / usr/sbin/keepalived-D

├─ 12058 / bin/bash / etc/keepalived/scripts/redis_backup.sh 127.0.0.1 10.0.37.225 6379

└─ 12061 sleep 15

Dec 03 21:56:26 ray0redis01 Keepalived_vrrp [5126]: / etc/keepalived/scripts/redis_check.sh exited with status 1

Dec 03 21:56:28 ray0redis01 Keepalived_vrrp [5126]: / etc/keepalived/scripts/redis_check.sh exited with status 1

Dec 03 21:56:30 ray0redis01 Keepalived_vrrp [5126]: / etc/keepalived/scripts/redis_check.sh exited with status 1

Dec 03 21:56:32 ray0redis01 Keepalived_vrrp [5126]: / etc/keepalived/scripts/redis_check.sh exited with status 1

Dec 03 21:56:34 ray0redis01 Keepalived_vrrp [5126]: / etc/keepalived/scripts/redis_check.sh exited with status 1

Dec 03 21:56:36 ray0redis01 Keepalived_vrrp [5126]: / etc/keepalived/scripts/redis_check.sh exited with status 1

Dec 03 21:56:38 ray0redis01 Keepalived_vrrp [5126]: VRRP_Script (chk_redis) succeeded

Dec 03 21:56:38 ray0redis01 Keepalived_vrrp [5126]: VRRP_Instance (redis) Entering BACKUP STATE

Dec 03 21:56:38 ray0redis01 Keepalived_vrrp [5126]: Opening script file / etc/keepalived/scripts/redis_backup.sh

Dec 03 21:56:39 ray0redis01 Keepalived_vrrp [5126]: VRRP_Instance (redis) forcing a new MASTER election

[root@ray0redis01 ~] #

[root@ray0redis01 ~] # systemctl status keepalived

● keepalived.service-LVS and VRRP High Availability Monitor

Loaded: loaded (/ usr/lib/systemd/system/keepalived.service; disabled; vendor preset: disabled)

Active: active (running) since Mon 2018-12-03 20:41:42 EST; 1h 15min ago

Process: 5122 ExecStart=/usr/sbin/keepalived $KEEPALIVED_OPTIONS (code=exited, status=0/SUCCESS)

Main PID: 5124 (keepalived)

CGroup: / system.slice/keepalived.service

├─ 5124 / usr/sbin/keepalived-D

├─ 5125 / usr/sbin/keepalived-D

└─ 5126 / usr/sbin/keepalived-D

Dec 03 21:56:41 ray0redis01 Keepalived_vrrp [5126]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 03 21:56:41 ray0redis01 Keepalived_vrrp [5126]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 03 21:56:41 ray0redis01 Keepalived_vrrp [5126]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 03 21:56:41 ray0redis01 Keepalived_vrrp [5126]: Opening script file / etc/keepalived/scripts/redis_master.sh

Dec 03 21:56:46 ray0redis01 Keepalived_vrrp [5126]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 03 21:56:46 ray0redis01 Keepalived_vrrp [5126]: VRRP_Instance (redis) Sending/queueing gratuitous ARPs on ens192 for 10.0.37.226

Dec 03 21:56:46 ray0redis01 Keepalived_vrrp [5126]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 03 21:56:46 ray0redis01 Keepalived_vrrp [5126]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 03 21:56:46 ray0redis01 Keepalived_vrrp [5126]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 03 21:56:46 ray0redis01 Keepalived_vrrp [5126]: Sending gratuitous ARP on ens192 for 10.0.37.226

[root@ray0redis01] # tail-f / var/log/keepalived-redis-state.log

Mon Dec 3 21:56:38 EST 2018

Run SLAVEOF cmd...

OK

[master]

Mon Dec 3 21:56:41 EST 2018

Being master....

Run MASTER cmd...

OK Already connected to specified master

Run SLAVEOF NO ONE cmd...

OK

[root@ray0redis02 ~] # systemctl status keepalived

● keepalived.service-LVS and VRRP High Availability Monitor

Loaded: loaded (/ usr/lib/systemd/system/keepalived.service; disabled; vendor preset: disabled)

Active: active (running) since Mon 2018-12-03 20:54:37 EST; 1h 2min ago

Process: 6112 ExecStart=/usr/sbin/keepalived $KEEPALIVED_OPTIONS (code=exited, status=0/SUCCESS)

Main PID: 6114 (keepalived)

CGroup: / system.slice/keepalived.service

├─ 6114 / usr/sbin/keepalived-D

├─ 6115 / usr/sbin/keepalived-D

└─ 6116 / usr/sbin/keepalived-D

Dec 03 21:54:44 ray0redis02 Keepalived_vrrp [6116]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 03 21:54:44 ray0redis02 Keepalived_vrrp [6116]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 03 21:54:44 ray0redis02 Keepalived_vrrp [6116]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 03 21:54:44 ray0redis02 Keepalived_vrrp [6116]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 03 21:56:38 ray0redis02 Keepalived_healthcheckers [6115]: TCP connection to [10.0.37.224]: 6379 success.

Dec 03 21:56:38 ray0redis02 Keepalived_healthcheckers [6115]: Adding service [10.0.37.224]: 6379 to VS [10.0.37.226]: 6379

Dec 03 21:56:39 ray0redis02 Keepalived_vrrp [6116]: VRRP_Instance (redis) Received advert with higher priority 100, ours 90

Dec 03 21:56:39 ray0redis02 Keepalived_vrrp [6116]: VRRP_Instance (redis) Entering BACKUP STATE

Dec 03 21:56:39 ray0redis02 Keepalived_vrrp [6116]: VRRP_Instance (redis) removing protocol VIPs.

Dec 03 21:56:39 ray0redis02 Keepalived_vrrp [6116]: Opening script file / etc/keepalived/scripts/redis_backup.sh

[root@ray0redis02] # tail-20f / var/log/messages

Dec 3 21:54:39 localhost Keepalived_vrrp [6116]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 3 21:54:39 localhost Keepalived_vrrp [6116]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 3 21:54:39 localhost Keepalived_vrrp [6116]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 3 21:54:39 localhost Keepalived_vrrp [6116]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 3 21:54:39 localhost NetworkManager: [1543892079.9698] policy: set-hostname: current hostname was changed outside NetworkManager: 'ray0redis02'

Dec 3 21:54:41 localhost Keepalived_healthcheckers [6115]: TCP connection to [10.0.37.224]: 6379 failed.

Dec 3 21:54:41 localhost Keepalived_healthcheckers [6115]: Check on service [10.0.37.224]: 6379 failed after 1 retry.

Dec 3 21:54:41 localhost Keepalived_healthcheckers [6115]: Removing service [10.0.37.224]: 6379 from VS [10.0.37.226]: 6379

Dec 3 21:54:44 localhost Keepalived_vrrp [6116]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 3 21:54:44 localhost Keepalived_vrrp [6116]: VRRP_Instance (redis) Sending/queueing gratuitous ARPs on ens192 for 10.0.37.226

Dec 3 21:54:44 localhost Keepalived_vrrp [6116]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 3 21:54:44 localhost Keepalived_vrrp [6116]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 3 21:54:44 localhost Keepalived_vrrp [6116]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 3 21:54:44 localhost Keepalived_vrrp [6116]: Sending gratuitous ARP on ens192 for 10.0.37.226

Dec 3 21:56:38 localhost Keepalived_healthcheckers [6115]: TCP connection to [10.0.37.224]: 6379 success.

Dec 3 21:56:38 localhost Keepalived_healthcheckers [6115]: Adding service [10.0.37.224]: 6379 to VS [10.0.37.226]: 6379

Dec 3 21:56:39 localhost Keepalived_vrrp [6116]: VRRP_Instance (redis) Received advert with higher priority 100, ours 90

Dec 3 21:56:39 localhost Keepalived_vrrp [6116]: VRRP_Instance (redis) Entering BACKUP STATE

Dec 3 21:56:39 localhost Keepalived_vrrp [6116]: VRRP_Instance (redis) removing protocol VIPs.

Dec 3 21:56:39 localhost NetworkManager: [1543892199.0770] policy: set-hostname: current hostname was changed outside NetworkManager: 'ray0redis02'

[root@ray0redis02] # tail-30 / var/log/keepalived-redis-state.log

Mon Dec 3 20:53:22 EST 2018

Run SLAVEOF cmd...

OK

[stop] 2018-12-03 20:54:37

[backup]

Mon Dec 3 20:54:37 EST 2018

Run SLAVEOF cmd...

OK

[master]

Mon Dec 3 20:55:59 EST 2018

Being master....

Run MASTER cmd...

OK Already connected to specified master

Run SLAVEOF NO ONE cmd...

OK

[backup]

Mon Dec 3 20:57:06 EST 2018

Run SLAVEOF cmd...

OK

[master]

Mon Dec 3 21:54:39 EST 2018

Being master....

Run MASTER cmd...

OK Already connected to specified master

Run SLAVEOF NO ONE cmd...

OK

[backup]

Mon Dec 3 21:56:39 EST 2018

Run SLAVEOF cmd...

OK

This is the end of the content of "how to configure redis master-slave switch in keepalived". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report