25
25
26
26
# #
27
27
# README.
28
- #
28
+ #
29
29
# This agent only supports being configured as a multistate Master
30
30
# resource.
31
31
#
49
49
# pcs resource create db galera enable_creation=true \
50
50
# wsrep_cluster_address="gcomm://rhel7-auto1,rhel7-auto2,rhel7-auto3" meta master-max=3 --master
51
51
#
52
- # By setting the 'enable_creation' option, the database will be automatically
52
+ # By setting the 'enable_creation' option, the database will be automatically
53
53
# generated at startup. The meta attribute 'master-max=3' means that all 3
54
54
# nodes listed in the wsrep_cluster_address list will be allowed to connect
55
55
# to the galera cluster and perform replication.
56
56
#
57
57
# NOTE: If you have more nodes in the pacemaker cluster then you wish
58
58
# to have in the galera cluster, make sure to use location contraints to prevent
59
59
# pacemaker from attempting to place a galera instance on a node that is
60
- # not in the 'wsrep_cluster_address" list.
60
+ # not in the 'wsrep_cluster_address" list.
61
61
#
62
62
# #
63
63
66
66
67
67
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT} / lib/ heartbeat}
68
68
. ${OCF_FUNCTIONS_DIR} /ocf-shellfuncs
69
- . ${OCF_FUNCTIONS_DIR} /mysql-common.sh
70
69
71
- NODENAME=$( ocf_attribute_target)
70
+ if [ " $__OCF_ACTION " != " meta-data" ]; then
71
+ . ${OCF_FUNCTIONS_DIR} /mysql-common.sh
72
+ NODENAME=$( ocf_attribute_target)
73
+ fi
72
74
73
75
# It is common for some galera instances to store
74
76
# check user that can be used to query status
99
101
}
100
102
101
103
meta_data () {
102
- cat << END
104
+ extra_parameters=" $1 "
105
+
106
+ cat << END
103
107
<?xml version="1.0"?>
104
108
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
105
109
<resource-agent name="galera">
@@ -247,6 +251,8 @@ Cluster check user password
247
251
<content type="string" default="" />
248
252
</parameter>
249
253
254
+ ${extra_parameters}
255
+
250
256
</parameters>
251
257
252
258
<actions>
@@ -329,7 +335,7 @@ get_last_commit()
329
335
330
336
if [ -z " $node " ]; then
331
337
${HA_SBIN_DIR} /crm_attribute -N $NODENAME -l reboot --name " ${INSTANCE_ATTR_NAME} -last-committed" --quiet 2> /dev/null
332
- else
338
+ else
333
339
${HA_SBIN_DIR} /crm_attribute -N $node -l reboot --name " ${INSTANCE_ATTR_NAME} -last-committed" --quiet 2> /dev/null
334
340
fi
335
341
}
@@ -418,7 +424,7 @@ clear_master_score()
418
424
local node=$( ocf_attribute_target $1 )
419
425
if [ -z " $node " ]; then
420
426
$CRM_MASTER -D
421
- else
427
+ else
422
428
$CRM_MASTER -D -N $node
423
429
fi
424
430
}
@@ -429,7 +435,7 @@ set_master_score()
429
435
430
436
if [ -z " $node " ]; then
431
437
$CRM_MASTER -v 100
432
- else
438
+ else
433
439
$CRM_MASTER -N $node -v 100
434
440
fi
435
441
}
@@ -912,64 +918,70 @@ galera_validate()
912
918
mysql_common_validate
913
919
}
914
920
915
- case " $1 " in
916
- meta-data) meta_data
917
- exit $OCF_SUCCESS ;;
918
- usage|help) usage
919
- exit $OCF_SUCCESS ;;
920
- esac
921
-
922
- galera_validate
923
- rc=$?
924
- LSB_STATUS_STOPPED=3
925
- if [ $rc -ne 0 ]; then
921
+ cmd_main () {
926
922
case " $1 " in
927
- stop) exit $OCF_SUCCESS ;;
928
- monitor) exit $OCF_NOT_RUNNING ;;
929
- status) exit $LSB_STATUS_STOPPED ;;
930
- * ) exit $rc ;;
923
+ meta-data) meta_data
924
+ exit $OCF_SUCCESS ;;
925
+ usage|help) usage
926
+ exit $OCF_SUCCESS ;;
931
927
esac
932
- fi
933
928
934
- if [ -z " ${OCF_RESKEY_check_passwd} " ]; then
935
- # This value is automatically sourced from /etc/sysconfig/checkcluster if available
936
- OCF_RESKEY_check_passwd=${MYSQL_PASSWORD}
937
- fi
938
- if [ -z " ${OCF_RESKEY_check_user} " ]; then
939
- # This value is automatically sourced from /etc/sysconfig/checkcluster if available
940
- OCF_RESKEY_check_user=${MYSQL_USERNAME}
941
- fi
942
- : ${OCF_RESKEY_check_user=" root" }
929
+ galera_validate
930
+ rc=$?
931
+ LSB_STATUS_STOPPED=3
932
+ if [ $rc -ne 0 ]; then
933
+ case " $1 " in
934
+ stop) exit $OCF_SUCCESS ;;
935
+ monitor) exit $OCF_NOT_RUNNING ;;
936
+ status) exit $LSB_STATUS_STOPPED ;;
937
+ * ) exit $rc ;;
938
+ esac
939
+ fi
943
940
944
- MYSQL_OPTIONS_CHECK=" -nNE --user=${OCF_RESKEY_check_user} "
945
- if [ -n " ${OCF_RESKEY_check_passwd} " ]; then
946
- MYSQL_OPTIONS_CHECK=" $MYSQL_OPTIONS_CHECK --password=${OCF_RESKEY_check_passwd} "
947
- fi
941
+ if [ -z " ${OCF_RESKEY_check_passwd} " ]; then
942
+ # This value is automatically sourced from /etc/sysconfig/checkcluster if available
943
+ OCF_RESKEY_check_passwd=${MYSQL_PASSWORD}
944
+ fi
945
+ if [ -z " ${OCF_RESKEY_check_user} " ]; then
946
+ # This value is automatically sourced from /etc/sysconfig/checkcluster if available
947
+ OCF_RESKEY_check_user=${MYSQL_USERNAME}
948
+ fi
949
+ : ${OCF_RESKEY_check_user=" root" }
948
950
949
- # This value is automatically sourced from /etc/sysconfig/checkcluster if available
950
- if [ -n " ${MYSQL_HOST } " ]; then
951
- MYSQL_OPTIONS_CHECK=" $MYSQL_OPTIONS_CHECK -h ${MYSQL_HOST }"
952
- fi
951
+ MYSQL_OPTIONS_CHECK= " -nNE --user= ${OCF_RESKEY_check_user} "
952
+ if [ -n " ${OCF_RESKEY_check_passwd } " ]; then
953
+ MYSQL_OPTIONS_CHECK=" $MYSQL_OPTIONS_CHECK --password= ${OCF_RESKEY_check_passwd }"
954
+ fi
953
955
954
- # This value is automatically sourced from /etc/sysconfig/checkcluster if available
955
- if [ -n " ${MYSQL_PORT } " ]; then
956
- MYSQL_OPTIONS_CHECK=" $MYSQL_OPTIONS_CHECK -P ${MYSQL_PORT } "
957
- fi
956
+ # This value is automatically sourced from /etc/sysconfig/checkcluster if available
957
+ if [ -n " ${MYSQL_HOST } " ]; then
958
+ MYSQL_OPTIONS_CHECK=" $MYSQL_OPTIONS_CHECK -h ${MYSQL_HOST } "
959
+ fi
958
960
961
+ # This value is automatically sourced from /etc/sysconfig/checkcluster if available
962
+ if [ -n " ${MYSQL_PORT} " ]; then
963
+ MYSQL_OPTIONS_CHECK=" $MYSQL_OPTIONS_CHECK -P ${MYSQL_PORT} "
964
+ fi
959
965
966
+ # What kind of method was invoked?
967
+ case " $1 " in
968
+ start) galera_start;;
969
+ stop) galera_stop;;
970
+ status) mysql_common_status err;;
971
+ monitor) galera_monitor;;
972
+ promote) galera_promote;;
973
+ demote) galera_demote;;
974
+ validate-all) exit $OCF_SUCCESS ;;
975
+
976
+ * ) usage
977
+ exit $OCF_ERR_UNIMPLEMENTED ;;
978
+ esac
979
+ }
960
980
961
- # What kind of method was invoked?
962
- case " $1 " in
963
- start) galera_start;;
964
- stop) galera_stop;;
965
- status) mysql_common_status err;;
966
- monitor) galera_monitor;;
967
- promote) galera_promote;;
968
- demote) galera_demote;;
969
- validate-all) exit $OCF_SUCCESS ;;
981
+ # run 'main' if we aren't "sourceonly"
982
+ if [ $1 != " sourceonly" ]; then
983
+ cmd_main " $@ "
984
+ fi
970
985
971
- * ) usage
972
- exit $OCF_ERR_UNIMPLEMENTED ;;
973
- esac
974
986
975
987
# vi:sw=4:ts=4:et:
0 commit comments