中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

keepalived怎么配置redis主從切換

發布時間:2021-09-14 17:49:22 來源:億速云 閱讀:198 作者:chen 欄目:建站服務器

本篇內容介紹了“keepalived怎么配置redis主從切換”的有關知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠學有所成!

IP規劃:

主節點:10.0.37.224

備節點:10.0.37.225

VIP:10.0.37.226 

一 2個節點安裝redis

1 安裝

[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 #將daemonize的值改為yes

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

#啟動

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

2 配置備節點slave信息

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

slaveof 10.0.37.224 6379

#啟動

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

二安裝keepalived

1 兩個節點都使用yum安裝keepalived

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

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

2 主節點keepalived配置文件

[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   ##需要修改為實際網卡名稱

    virtual_router_id 60

    priority 100          ##權重,數字越大權重越大,主節點數值大于備節點

    advert_int 1

authentication {   #all node must same

        auth_type PASS

        auth_pass 1111

    }

    virtual_ipaddress {

        10.0.37.226     ##需要修改為實際分配的虛擬IP

    }

    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需要修改為實際的遠端主機IP

    notify_backup "/etc/keepalived/scripts/redis_backup.sh 127.0.0.1 10.0.37.225 6379"     ## 10.0.37.225需要修改為實際的遠端主機IP

    notify_fault /etc/keepalived/scripts/redis_fault.sh

    notify_stop /etc/keepalived/scripts/redis_stop.sh

}


3 備節點keepalived配置文件

[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   ##需要修改為實際網卡名稱

    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     ##需要修改為實際分配的虛擬IP

    }

    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需要修改為實際的遠端主機IP

    notify_backup "/etc/keepalived/scripts/redis_backup.sh 127.0.0.1 10.0.37.224 6379"     ## 10.0.37.224需要修改為實際的遠端主機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 兩個節點所有的腳本

[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

三 啟動keepalived,驗證HA的情況和切換

[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

#殺掉redis進程

[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.

#觀察備節點狀態,完成切換

[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[758]: <info>  [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

#啟動主節點,keepalived和redis切換回主節點

[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[758]: <info>  [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[758]: <info>  [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

“keepalived怎么配置redis主從切換”的內容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業相關的知識可以關注億速云網站,小編將為大家輸出更多高質量的實用文章!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

庄浪县| 集贤县| 峡江县| 江口县| 永和县| 景泰县| 高州市| 维西| 金乡县| 威远县| 满城县| 荃湾区| 嘉禾县| 土默特右旗| 榕江县| 徐州市| 东安县| 垫江县| 肇庆市| 南岸区| 扎囊县| 邹平县| 丽江市| 长沙市| 兰溪市| 东辽县| 两当县| 蒙山县| 砀山县| 宜兴市| 宁蒗| 高青县| 镇坪县| 来凤县| 辰溪县| 徐水县| 邹城市| 凤阳县| 治多县| 塘沽区| 岳阳市|