Skip to content

Commit

Permalink
Merge pull request #325 from davidvossel/mysql_nodename_fix
Browse files Browse the repository at this point in the history
Low: mysql: Using crm_node -n for instance attributes instead of uname -n
  • Loading branch information
davidvossel committed Dec 2, 2013
2 parents 2495f15 + 27087ff commit 733a472
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
3 changes: 2 additions & 1 deletion heartbeat/SAPInstance
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ sapinstance_notify() {
# that is, when a slave resource was startet after the promote event of a already running master (e.g. node of slave was down)
# We also have to make sure to overrule the globaly set resource_stickiness or any fail-count factors => INFINITY
local n_uname="$OCF_RESKEY_CRM_meta_notify_demote_uname"
if [ ${n_uname} != ${HOSTNAME} ]; then
if [ ${n_uname} != ${NODENAME} ]; then
${HA_SBIN_DIR}/crm_master -v INFINITY -l reboot
fi
fi
Expand All @@ -879,6 +879,7 @@ SAPCONTROL=""
DIR_PROFILE=""
SAPSTARTPROFILE=""
CLONE=0
NODENAME=$(ocf_local_nodename)


if
Expand Down
12 changes: 6 additions & 6 deletions heartbeat/mysql
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ MYSQL_OPTIONS_TEST="$MYSQL_OPTIONS_LOCAL --user=$OCF_RESKEY_test_user --password
MYSQL_TOO_MANY_CONN_ERR=1040

CRM_MASTER="${HA_SBIN_DIR}/crm_master -l reboot "
HOSTNAME=`uname -n`
CRM_ATTR="${HA_SBIN_DIR}/crm_attribute -N $HOSTNAME "
NODENAME=$(ocf_local_nodename)
CRM_ATTR="${HA_SBIN_DIR}/crm_attribute -N $NODENAME "
INSTANCE_ATTR_NAME=`echo ${OCF_RESOURCE_INSTANCE}| awk -F : '{print $1}'`
CRM_ATTR_REPL_INFO="${HA_SBIN_DIR}/crm_attribute --type crm_config --name ${INSTANCE_ATTR_NAME}_REPL_INFO -s mysql_replication"

Expand Down Expand Up @@ -998,7 +998,7 @@ mysql_start() {
# node that is just joining the cluster, and the CRM may have
# promoted a master before.
master_host=`echo $OCF_RESKEY_CRM_meta_notify_master_uname|tr -d " "`
if [ "$master_host" -a "$master_host" != ${HOSTNAME} ]; then
if [ "$master_host" -a "$master_host" != ${NODENAME} ]; then
ocf_log info "Changing MySQL configuration to replicate from $master_host."
set_master
start_slave
Expand Down Expand Up @@ -1147,7 +1147,7 @@ mysql_notify() {
# time to check whether our replication slave is working
# correctly.
master_host=`echo $OCF_RESKEY_CRM_meta_notify_promote_uname|tr -d " "`
if [ "$master_host" = ${HOSTNAME} ]; then
if [ "$master_host" = ${NODENAME} ]; then
ocf_log info "This will be the new master, ignoring post-promote notification."
else
ocf_log info "Resetting replication"
Expand All @@ -1172,7 +1172,7 @@ mysql_notify() {
;;
'pre-demote')
demote_host=`echo $OCF_RESKEY_CRM_meta_notify_demote_uname|tr -d " "`
if [ $demote_host = ${HOSTNAME} ]; then
if [ $demote_host = ${NODENAME} ]; then
ocf_log info "post-demote notification for $demote_host"
set_read_only on
if [ $? -ne 0 ]; then
Expand All @@ -1199,7 +1199,7 @@ mysql_notify() {
;;
'post-demote')
demote_host=`echo $OCF_RESKEY_CRM_meta_notify_demote_uname|tr -d " "`
if [ $demote_host = ${HOSTNAME} ]; then
if [ $demote_host = ${NODENAME} ]; then
ocf_log info "Ignoring post-demote notification for my own demotion."
return $OCF_SUCCESS
fi
Expand Down
19 changes: 19 additions & 0 deletions heartbeat/ocf-shellfuncs.in
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,25 @@ ocf_version_cmp() {
fi
}

ocf_local_nodename() {
# use crm_node -n for pacemaker > 1.1.8
which pacemakerd > /dev/null 2>&1
if [ $? -eq 0 ]; then
local version=$(pacemakerd -$ | grep "Pacemaker .*" | awk '{ print $2 }')
ocf_version_cmp "$version" "1.1.8"
if [ $? -eq 2 ]; then
which crm_node > /dev/null 2>&1
if [ $? -eq 0 ]; then
crm_node -n
return
fi
fi
fi

# otherwise use uname -n
uname -n
}

# usage: dirname DIR
dirname()
{
Expand Down
2 changes: 1 addition & 1 deletion heartbeat/pgsql
Original file line number Diff line number Diff line change
Expand Up @@ -1746,7 +1746,7 @@ BACKUPLABEL=${OCF_RESKEY_pgdata}/backup_label
RESOURCE_NAME=`echo $OCF_RESOURCE_INSTANCE | cut -d ":" -f 1`
PGSQL_WAL_RECEIVER_STATUS_ATTR="${RESOURCE_NAME}-receiver-status"
RECOVERY_CONF=${OCF_RESKEY_pgdata}/recovery.conf
NODENAME=`uname -n | tr '[A-Z]' '[a-z]'`
NODENAME=$(ocf_local_nodename | tr '[A-Z]' '[a-z]')

if is_replication; then
REP_MODE_CONF=${OCF_RESKEY_tmpdir}/rep_mode.conf
Expand Down

0 comments on commit 733a472

Please sign in to comment.