#!/bin/bash -e #!/bin/bash -eu #==============================================================================# # # http://www.fromdual.com/unbreakable-mysql-cluster-with-galera-and-lvs # http://galeracluster.com/documentation-webpages/mysqlwsrepoptions.html#wsrep-notify-cmd # # /etc/mysql/galera_mariadb.cnf # # [mysqld] # wsrep_notify_cmd = /var/lib/mysql/bin/wsrep_notify_cmd.sh # #==============================================================================# # # Warning! # # The node will block and wait until the script completes and returns before it # can proceed. If the script performs any potentially blocking or long-running # operations, such as network communication, you may wish initiate such # operations in the background and have the script return immediately. # #==============================================================================# # # SET GLOBAL wsrep_notify_cmd='/var/lib/mysql/bin/wsrep_notify_cmd.sh'; # SHOW VARIABLES LIKE 'wsrep_notify_cmd'; # #==============================================================================# #MYIP='' VERSION="v2017110800" LOG="/var/log/mysql/wsrep_notify_cmd.log" #ETC="/etc/mysql/conf.d/wsrep.cnf" #ETC="/home/mysql/data/mysql-5.5-wsrep-23.7-a/my.cnf" ETC="/etc/mysql/galera_mariadb.cnf" DATUM_ZEIT="$(date +'%Y-%m-%d %H:%M:%S')" echo "${DATUM_ZEIT}" >>${LOG} echo "${0} ${@}" >>${LOG} #------------------------------------------------------------------------------# #regex='^.*=\s*([0-9]+.[0-9]+.[0-9]+.[0-9]+).*' # #str=$(grep -E "^wsrep_node_incoming_address" ${ETC} 2>>${LOG}) # #if [[ ${str} =~ ${regex} ]] ; then # MYIP=${BASH_REMATCH[1]} #else # echo "Cannot find IP address in ${str}" >>${LOG} # exit 1 #fi #------------------------------------------------------------------------------# while [ "${#}" -gt "0" ] ; do case "${1}" in --status) # Undefined, Joiner, Donor, Joined, Synced, Error STATUS="$2" shift ;; --uuid) # The cluster state UUID. CLUSTER_UUID="$2" shift ;; --primary) # yes, no PRIMARY="$2" shift ;; --index) # The index of this node in the node list. INDEX="$2" shift ;; --members) # eine durch Komma getrennte Liste mit UUIDs MEMBERS="$2" shift ;; esac shift done #------------------------------------------------------------------------------# # echo $* >> ${LOG} echo " STATUS=${STATUS} CLUSTER_UUID=${CLUSTER_UUID} PRIMARY=${PRIMARY} INDEX=${INDEX} MEMBERS=${MEMBERS} " >>${LOG} # Undefined means node is shutting down # Synced means node is ready again #if [ "${STATUS}" = "Synced" -a "${PRIMARY}" = "[Yy][Ee][Ss]" ] ; then if [ "${STATUS}" = "Synced" ] ; then #DB_STAT="System ist bereit: ${STATUS},${PRIMARY}" DB_STAT="System ist bereit: ${STATUS}" else #DB_STAT="System ist nicht bereit: ${STATUS},${PRIMARY}" DB_STAT="System ist nicht bereit: ${STATUS}" fi echo "${DB_STAT}" >>${LOG} echo "ret=$?" >>${LOG} echo "#------------------------------------------------------------------------------#" >>${LOG} exit 0