f6e8478b61
We use the wsrep_notify.sh script to notify changes in Galera cluster membership to haproxy. When xtrabackup was used for the state transfer, nodes in the Donor state would be included in the backend pool. However, since the switch to mariabackup in the Stein cycle, we now remove nodes in the Donor state from the backend pool. This change ensures that nodes in the Donor state are included in the backend pool when the SST method is either xtrabackup or mariabackup. https://galeracluster.com/library/documentation/mysql-wsrep-options.html#wsrep-notify-cmd Change-Id: Ide4301779a0d221ae5d4dbdd4873fb8a40eb7297 Co-authored-by: Radosław Piliszek <radoslaw.piliszek@gmail.com> Closes-Bug: #1850945
80 lines
1.4 KiB
Django/Jinja
80 lines
1.4 KiB
Django/Jinja
#!/bin/bash -e
|
|
|
|
# Edit parameters below to specify the address and login to server.
|
|
USER={{ database_user }}
|
|
PSWD={{ database_password }}
|
|
HOST={{ api_interface_address }}
|
|
PORT={{ mariadb_port }}
|
|
LB_USER=haproxy
|
|
|
|
ENABLE_LB="UPDATE mysql.user SET User='${LB_USER}' WHERE User='${LB_USER}_blocked';"
|
|
DISABLE_LB="UPDATE mysql.user SET User='${LB_USER}_blocked' WHERE User='${LB_USER}';"
|
|
MYSQL_CMD="`type -p mysql` -B -u$USER -p$PSWD -h$HOST -P$PORT"
|
|
|
|
status_update()
|
|
{
|
|
echo "SET SESSION wsrep_on=off;"
|
|
echo "$@"
|
|
echo "FLUSH PRIVILEGES;"
|
|
}
|
|
|
|
get_sst_method()
|
|
{
|
|
$MYSQL_CMD -s -N -e "SHOW VARIABLES LIKE 'wsrep_sst_method';" | awk '{ print $2 }'
|
|
}
|
|
|
|
while [ $# -gt 0 ]
|
|
do
|
|
case $1 in
|
|
--status)
|
|
STATUS=$2
|
|
shift
|
|
;;
|
|
--uuid)
|
|
CLUSTER_UUID=$2
|
|
shift
|
|
;;
|
|
--primary)
|
|
[ "$2" = "yes" ] && PRIMARY="1" || PRIMARY="0"
|
|
shift
|
|
;;
|
|
--index)
|
|
INDEX=$2
|
|
shift
|
|
;;
|
|
--members)
|
|
MEMBERS=$2
|
|
shift
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
case $STATUS in
|
|
Synced)
|
|
CMD=$ENABLE_LB
|
|
;;
|
|
Donor)
|
|
# enabling donor only if xtrabackup configured
|
|
SST_METHOD=`get_sst_method`
|
|
if [[ $SST_METHOD =~ (mariabackup|xtrabackup) ]]; then
|
|
CMD=$ENABLE_LB
|
|
else
|
|
CMD=$DISABLE_LB
|
|
fi
|
|
;;
|
|
Undefined)
|
|
# shutting down database: do nothing
|
|
;;
|
|
*)
|
|
CMD=$DISABLE_LB
|
|
;;
|
|
esac
|
|
|
|
if [ -n "$CMD" ]
|
|
then
|
|
status_update "$CMD" | $MYSQL_CMD
|
|
fi
|
|
|
|
exit 0
|