File tree Expand file tree Collapse file tree 1 file changed +58
-0
lines changed
Expand file tree Collapse file tree 1 file changed +58
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ export PATH=/opt/redislabs/bin:$PATH
3+
4+
5+ get_endpoint () {
6+ result=` rladmin status | grep $1 | grep single`
7+ echo $result
8+ }
9+
10+
11+ get_public_ip () {
12+ result=` rladmin status | tr -s ' ' | grep " node:$1 " | grep ' /' | cut -d' ' -f4`
13+ echo $result
14+ }
15+
16+ time_s () {
17+ result=` date +%s`
18+ echo $result
19+ }
20+
21+ DB_NAME=hitless-upgrade
22+ DB_PWD=test123
23+ DB_PORT=17630
24+ EP=` get_endpoint $DB_NAME `
25+
26+
27+ DB_ID=` echo $EP | cut -d' ' -f1 | cut -d' :' -f2`
28+ EP_ID=` echo $EP | cut -d' ' -f3 | cut -d' :' -f2,3`
29+ EP_CURR=` echo $EP | cut -d' ' -f4 | cut -d' :' -f2`
30+ EP_TO=-1
31+
32+ if [ " $EP_CURR " -eq 2 ]
33+ then
34+ EP_TO=1
35+ elif [ " $EP_CURR " -eq 1 ]
36+ then
37+ EP_TO=2
38+ fi
39+
40+ EP_CURR_IP=` get_public_ip $EP_CURR `
41+ EP_TO_IP=` get_public_ip $EP_TO `
42+
43+ echo " ` time_s` - Rebinding endpoint $EP_ID from $EP_CURR_IP to $EP_TO_IP ..."
44+ rladmin bind endpoint $EP_ID include $EP_TO
45+ echo " ` time_s` - Included the new endpoint $EP_TO_IP ."
46+ sleep 5
47+
48+ # redis-cli -3 -h $EP_CURR_IP -p $DB_PORT -a $DB_PWD PUBLISH __rebind "type=rebind;from_ep=$EP_CURR_IP:$DB_PORT;to_ep=$EP_TO_IP:$DB_PORT;until_s=10"
49+ msg_payload=$( printf ' ["MOVING",30,"%s:%s"]' " $EP_TO_IP " " $DB_PORT " )
50+ ccs-cli HSET endpoint:$EP_ID push_notification $msg_payload
51+ ccs-cli HSET bdb:$DB_ID _changestate:dmc:$EP_CURR pending
52+ ccs-cli PUBLISH config-change:dmc:$EP_CURR @bdb:$DB_ID
53+
54+ echo " Notified the client."
55+ sleep 10
56+ echo " ` time_s` - Completing the rebind ..."
57+ rladmin bind endpoint $EP_ID exclude $EP_CURR
58+ echo " ` time_s` - Excluded the previous endpoint $EP_CURR_IP ."
You can’t perform that action at this time.
0 commit comments