|
|
79554c |
From aa486941a7d980ded7a30e404a9d91620b19c47a Mon Sep 17 00:00:00 2001
|
|
|
79554c |
From: Damien Ciabrini <dciabrin@redhat.com>
|
|
|
79554c |
Date: Mon, 19 Dec 2016 14:13:21 +0100
|
|
|
79554c |
Subject: [PATCH] galera: allow names in wsrep_cluster_address to differ from
|
|
|
79554c |
pacemaker nodes' names
|
|
|
79554c |
|
|
|
79554c |
Add a new option cluster_host_map to the galera resource agent in case
|
|
|
79554c |
names to be used in wsrep_cluster_address need to differ from names
|
|
|
79554c |
used for the pacemaker nodes. (e.g. when galera names map to IP
|
|
|
79554c |
from a specific network interface)
|
|
|
79554c |
---
|
|
|
79554c |
heartbeat/galera | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++-----
|
|
|
79554c |
1 file changed, 65 insertions(+), 6 deletions(-)
|
|
|
79554c |
|
|
|
79554c |
diff --git a/heartbeat/galera b/heartbeat/galera
|
|
|
79554c |
index fe2aa8a..45693ac 100755
|
|
|
79554c |
--- a/heartbeat/galera
|
|
|
79554c |
+++ b/heartbeat/galera
|
|
|
79554c |
@@ -208,13 +208,30 @@ The galera cluster address. This takes the form of:
|
|
|
79554c |
gcomm://node,node,node
|
|
|
79554c |
|
|
|
79554c |
Only nodes present in this node list will be allowed to start a galera instance.
|
|
|
79554c |
-It is expected that the galera node names listed in this address match valid
|
|
|
79554c |
-pacemaker node names.
|
|
|
79554c |
+The galera node names listed in this address are expected to match valid
|
|
|
79554c |
+pacemaker node names. If both names need to differ, you must provide a
|
|
|
79554c |
+mapping in option cluster_host_map.
|
|
|
79554c |
</longdesc>
|
|
|
79554c |
<shortdesc lang="en">Galera cluster address</shortdesc>
|
|
|
79554c |
<content type="string" default=""/>
|
|
|
79554c |
</parameter>
|
|
|
79554c |
|
|
|
79554c |
+<parameter name="cluster_host_map" unique="0" required="0">
|
|
|
79554c |
+<longdesc lang="en">
|
|
|
79554c |
+A mapping of pacemaker node names to galera node names.
|
|
|
79554c |
+
|
|
|
79554c |
+To be used when both pacemaker and galera names need to differ,
|
|
|
79554c |
+(e.g. when galera names map to IP from a specific network interface)
|
|
|
79554c |
+This takes the form of:
|
|
|
79554c |
+pcmk1:node.1.galera;pcmk2:node.2.galera;pcmk3:node.3.galera
|
|
|
79554c |
+
|
|
|
79554c |
+where the galera resource started on node pcmk1 would be named
|
|
|
79554c |
+node.1.galera in the wsrep_cluster_address
|
|
|
79554c |
+</longdesc>
|
|
|
79554c |
+<shortdesc lang="en">Pacemaker to Galera name mapping</shortdesc>
|
|
|
79554c |
+<content type="string" default=""/>
|
|
|
79554c |
+</parameter>
|
|
|
79554c |
+
|
|
|
79554c |
<parameter name="check_user" unique="0" required="0">
|
|
|
79554c |
<longdesc lang="en">
|
|
|
79554c |
Cluster check user.
|
|
|
79554c |
@@ -454,6 +471,27 @@ greater_than_equal_long()
|
|
|
79554c |
echo | awk -v n1="$1" -v n2="$2" '{if (n1>=n2) printf ("true"); else printf ("false");}' | grep -q "true"
|
|
|
79554c |
}
|
|
|
79554c |
|
|
|
79554c |
+galera_to_pcmk_name()
|
|
|
79554c |
+{
|
|
|
79554c |
+ local galera=$1
|
|
|
79554c |
+ if [ -z "$OCF_RESKEY_cluster_host_map" ]; then
|
|
|
79554c |
+ echo $galera
|
|
|
79554c |
+ else
|
|
|
79554c |
+ echo "$OCF_RESKEY_cluster_host_map" | tr ';' '\n' | tr -d ' ' | sed 's/:/ /' | awk -F' ' '$2=="'"$galera"'" {print $1;exit}'
|
|
|
79554c |
+ fi
|
|
|
79554c |
+}
|
|
|
79554c |
+
|
|
|
79554c |
+pcmk_to_galera_name()
|
|
|
79554c |
+{
|
|
|
79554c |
+ local pcmk=$1
|
|
|
79554c |
+ if [ -z "$OCF_RESKEY_cluster_host_map" ]; then
|
|
|
79554c |
+ echo $pcmk
|
|
|
79554c |
+ else
|
|
|
79554c |
+ echo "$OCF_RESKEY_cluster_host_map" | tr ';' '\n' | tr -d ' ' | sed 's/:/ /' | awk -F' ' '$1=="'"$pcmk"'" {print $2;exit}'
|
|
|
79554c |
+ fi
|
|
|
79554c |
+}
|
|
|
79554c |
+
|
|
|
79554c |
+
|
|
|
79554c |
detect_first_master()
|
|
|
79554c |
{
|
|
|
79554c |
local best_commit=0
|
|
|
79554c |
@@ -465,6 +503,14 @@ detect_first_master()
|
|
|
79554c |
|
|
|
79554c |
# avoid selecting a recovered node as bootstrap if possible
|
|
|
79554c |
for node in $(echo "$OCF_RESKEY_wsrep_cluster_address" | sed 's/gcomm:\/\///g' | tr -d ' ' | tr -s ',' ' '); do
|
|
|
79554c |
+ local pcmk_node=$(galera_to_pcmk_name $node)
|
|
|
79554c |
+ if [ -z "$pcmk_node" ]; then
|
|
|
79554c |
+ ocf_log error "Could not determine pacemaker node from galera name <${node}>."
|
|
|
79554c |
+ return
|
|
|
79554c |
+ else
|
|
|
79554c |
+ node=$pcmk_node
|
|
|
79554c |
+ fi
|
|
|
79554c |
+
|
|
|
79554c |
if is_no_grastate $node; then
|
|
|
79554c |
nodes_recovered="$nodes_recovered $node"
|
|
|
79554c |
else
|
|
|
79554c |
@@ -783,10 +829,17 @@ galera_demote()
|
|
|
79554c |
galera_start()
|
|
|
79554c |
{
|
|
|
79554c |
local rc
|
|
|
79554c |
+ local galera_node
|
|
|
79554c |
+
|
|
|
79554c |
+ galera_node=$(pcmk_to_galera_name $NODENAME)
|
|
|
79554c |
+ if [ -z "$galera_node" ]; then
|
|
|
79554c |
+ ocf_exit_reason "Could not determine galera name from pacemaker node <${NODENAME}>."
|
|
|
79554c |
+ return $OCF_ERR_CONFIGURED
|
|
|
79554c |
+ fi
|
|
|
79554c |
|
|
|
79554c |
- echo $OCF_RESKEY_wsrep_cluster_address | grep -q $NODENAME
|
|
|
79554c |
+ echo $OCF_RESKEY_wsrep_cluster_address | grep -q -F $galera_node
|
|
|
79554c |
if [ $? -ne 0 ]; then
|
|
|
79554c |
- ocf_exit_reason "local node <${NODENAME}> must be a member of the wsrep_cluster_address <${OCF_RESKEY_wsrep_cluster_address}>to start this galera instance"
|
|
|
79554c |
+ ocf_exit_reason "local node <${NODENAME}> (galera node <${galera_node}>) must be a member of the wsrep_cluster_address <${OCF_RESKEY_wsrep_cluster_address}> to start this galera instance"
|
|
|
79554c |
return $OCF_ERR_CONFIGURED
|
|
|
79554c |
fi
|
|
|
79554c |
|
|
|
79554c |
@@ -818,6 +871,7 @@ galera_start()
|
|
|
79554c |
galera_monitor()
|
|
|
79554c |
{
|
|
|
79554c |
local rc
|
|
|
79554c |
+ local galera_node
|
|
|
79554c |
local status_loglevel="err"
|
|
|
79554c |
|
|
|
79554c |
# Set loglevel to info during probe
|
|
|
79554c |
@@ -857,10 +911,15 @@ galera_monitor()
|
|
|
79554c |
fi
|
|
|
79554c |
|
|
|
79554c |
# if we make it here, mysql is running. Check cluster status now.
|
|
|
79554c |
+ galera_node=$(pcmk_to_galera_name $NODENAME)
|
|
|
79554c |
+ if [ -z "$galera_node" ]; then
|
|
|
79554c |
+ ocf_exit_reason "Could not determine galera name from pacemaker node <${NODENAME}>."
|
|
|
79554c |
+ return $OCF_ERR_CONFIGURED
|
|
|
79554c |
+ fi
|
|
|
79554c |
|
|
|
79554c |
- echo $OCF_RESKEY_wsrep_cluster_address | grep -q $NODENAME
|
|
|
79554c |
+ echo $OCF_RESKEY_wsrep_cluster_address | grep -q -F $galera_node
|
|
|
79554c |
if [ $? -ne 0 ]; then
|
|
|
79554c |
- ocf_exit_reason "local node <${NODENAME}> is started, but is not a member of the wsrep_cluster_address <${OCF_RESKEY_wsrep_cluster_address}>"
|
|
|
79554c |
+ ocf_exit_reason "local node <${NODENAME}> (galera node <${galera_node}>) is started, but is not a member of the wsrep_cluster_address <${OCF_RESKEY_wsrep_cluster_address}>"
|
|
|
79554c |
return $OCF_ERR_GENERIC
|
|
|
79554c |
fi
|
|
|
79554c |
|