Skip to content

Commit

Permalink
Merge pull request #29 from percona/v1.3.2-dev
Browse files Browse the repository at this point in the history
Fixed BLD-603 and BLD-604
  • Loading branch information
rameshvs02 authored Jan 13, 2017
2 parents 9024225 + 614416b commit 825b441
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
18 changes: 9 additions & 9 deletions proxysql-admin
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fi
usage () {
echo "Usage: [ options ]"
echo "Options:"
echo " --config-file Read login credentials form a configuration file (overrides any login credentials specified on the command line)"
echo " --config-file Read login credentials from a configuration file (overrides any login credentials specified on the command line)"
echo " --quick-demo Setup a quick demo with no authentication"
echo " --proxysql-username=user_name Username for connecting to the ProxySQL service"
echo " --proxysql-password[=password] Password for connecting to the ProxySQL service"
Expand All @@ -41,9 +41,9 @@ usage () {
echo " --monitor-password[=password] Password for monitoring Percona XtraDB Cluster nodes through ProxySQL"
echo " --enable, -e Auto-configure Percona XtraDB Cluster nodes into ProxySQL"
echo " --disable, -d Remove any Percona XtraDB Cluster configurations from ProxySQL"
echo " --node-check-interval Interval for monitoring node checker script (in milliseconds)"
echo " --mode ProxySQL read/write configuration mode, currently supporting: 'loadbal' and 'singlewrite' (the default) modes"
echo " --write-node Writer node to accept write statments. This option is supported only when using --mode=singlewrite"
echo " --node-check-interval=3000 Interval for monitoring node checker script (in milliseconds)"
echo " --mode=[loadbal|singlewrite] ProxySQL read/write configuration mode, currently supporting: 'loadbal' and 'singlewrite' (the default) modes"
echo " --write-node=host_name:port Writer node to accept write statments. This option is supported only when using --mode=singlewrite"
echo " --adduser Adds the Percona XtraDB Cluster application user to the ProxySQL database"
echo " --version, -v Print version info"
}
Expand Down Expand Up @@ -177,8 +177,8 @@ do
shift
disable=1
;;
--galera-check-interval )
GALERA_CHECK_INTERVAL="$2"
--node-check-interval )
NODE_CHECK_INTERVAL="$2"
shift 2
;;
--mode )
Expand Down Expand Up @@ -319,8 +319,8 @@ else
CLUSTER_APP_PASSWORD=''
fi

if [[ -z "$GALERA_CHECK_INTERVAL" ]]; then
GALERA_CHECK_INTERVAL=3000
if [[ -z "$NODE_CHECK_INTERVAL" ]]; then
NODE_CHECK_INTERVAL=3000
fi

if [[ -z "$MODE" ]]; then
Expand Down Expand Up @@ -592,7 +592,7 @@ enable_proxysql(){
# Adding proxysql galera check scheduler
proxysql_exec "DELETE FROM SCHEDULER WHERE ID=10;"
check_cmd $?
proxysql_exec "INSERT INTO SCHEDULER (id,active,interval_ms,filename,arg1,arg2,arg3,arg4,arg5) VALUES (10,1,$GALERA_CHECK_INTERVAL,'$PROXYSQL_GALERA_CHECK',$WRITE_HOSTGROUP_ID,$READ_HOSTGROUP_ID,${#wsrep_address[@]},1,'/var/lib/proxysql/proxysql_galera_check.log');"
proxysql_exec "INSERT INTO SCHEDULER (id,active,interval_ms,filename,arg1,arg2,arg3,arg4,arg5) VALUES (10,1,$NODE_CHECK_INTERVAL,'$PROXYSQL_GALERA_CHECK',$WRITE_HOSTGROUP_ID,$READ_HOSTGROUP_ID,${#wsrep_address[@]},1,'/var/lib/proxysql/proxysql_galera_check.log');"
check_cmd $? "Failed to add the Percona XtraDB Cluster monitoring scheduler in ProxySQL"

# Adding Percona XtraDB Cluster membership checking scheduler
Expand Down
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 825b441

Please sign in to comment.