Skip to content

Commit

Permalink
Fixed BLD-604
Browse files Browse the repository at this point in the history
  • Loading branch information
rameshvs02 committed Jan 13, 2017
1 parent 3482870 commit 614416b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions proxysql_node_monitor
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ update_cluster(){
ws_ip=$(echo $i | cut -d':' -f1)
ws_port=$(echo $i | cut -d':' -f2)
echo "Node ${i} does not exists in cluster membership!" >> $ERR_FILE
proxysql_exec "UPDATE mysql_servers set status = 'OFFLINE_HARD' WHERE hostgroup_id = $HOSTGROUP_ID and hostname='$ws_ip' and port=$ws_port;"
proxysql_exec "UPDATE mysql_servers set status = 'OFFLINE_HARD', weight=1000 WHERE hostgroup_id = $HOSTGROUP_ID and hostname='$ws_ip' and port=$ws_port;"
check_cmd $? "Cannot update Percona XtraDB Cluster node $ws_ip:$ws_port to ProxySQL database, Please check proxysql credentials"
proxysql_exec "LOAD MYSQL SERVERS TO RUNTIME; SAVE MYSQL SERVERS TO DISK;"
echo "${i} node set to OFFLINE_HARD status to ProxySQL database." >> $ERR_FILE
Expand All @@ -84,7 +84,7 @@ update_cluster(){
ws_status=$(echo `proxysql_exec "SELECT status from mysql_servers WHERE hostname='$ws_ip' and port=$ws_port"`)
echo "Cluster node (${i}) current status '$ws_status' in ProxySQL database!" >> $ERR_FILE
if [ "$ws_status" == "OFFLINE_HARD" ]; then
proxysql_exec "UPDATE mysql_servers set status = 'OFFLINE_SOFT' WHERE hostname='$ws_ip' and port=$ws_port;"
proxysql_exec "UPDATE mysql_servers set status = 'OFFLINE_SOFT', weight=1000 WHERE hostname='$ws_ip' and port=$ws_port;"
check_cmd $? "Cannot update Percona XtraDB Cluster node $ws_ip:$ws_port to ProxySQL database, Please check proxysql credentials"
proxysql_exec "LOAD MYSQL SERVERS TO RUNTIME; SAVE MYSQL SERVERS TO DISK;"
echo "${i} node set to OFFLINE_SOFT status to ProxySQL database." >> $ERR_FILE
Expand All @@ -99,12 +99,12 @@ update_cluster(){
mode_change_check(){
checkwriter_hid=`proxysql_exec "select hostgroup_id from mysql_servers where comment='WRITE' and status='OFFLINE_SOFT'"`
if [[ -n "$checkwriter_hid" ]]; then
proxysql_exec "UPDATE mysql_servers set hostgroup_id = $READ_HOSTGROUP_ID, comment='READ' WHERE comment='WRITE' and status='OFFLINE_SOFT'"
proxysql_exec "UPDATE mysql_servers set hostgroup_id = $READ_HOSTGROUP_ID, comment='READ', weight=1000 WHERE comment='WRITE' and status='OFFLINE_SOFT'"
check_cmd $? "Cannot update Percona XtraDB Cluster writer node in ProxySQL database, Please check proxysql credentials"
current_hosts=(`proxysql_exec "SELECT hostname,port FROM mysql_servers WHERE status='ONLINE' and comment='READ' ORDER BY random() LIMIT 1" | sed 's|\t|:|g' | tr '\n' ' '`)
ws_ip=$(echo $current_hosts | cut -d':' -f1)
ws_port=$(echo $current_hosts | cut -d':' -f2)
proxysql_exec "UPDATE mysql_servers set hostgroup_id = $WRITE_HOSTGROUP_ID, comment='WRITE' WHERE hostname='$ws_ip' and port=$ws_port"
proxysql_exec "UPDATE mysql_servers set hostgroup_id = $WRITE_HOSTGROUP_ID, comment='WRITE', weight=1000000 WHERE hostname='$ws_ip' and port=$ws_port"
check_cmd $? "Cannot update Percona XtraDB Cluster writer node in ProxySQL database, Please check proxysql credentials"
proxysql_exec "LOAD MYSQL SERVERS TO RUNTIME; SAVE MYSQL SERVERS TO DISK;"
fi
Expand Down

0 comments on commit 614416b

Please sign in to comment.