start-sandbox: If starting a cluster node that isn't the first one in the cluster, change the first's wsrep_cluster_address. This stops /tmp/12345/stop; /tmp/12345/start from creating a second cluster -- instead, it rejoins the original

This commit is contained in:
Brian Fraser
2012-12-11 18:43:45 -03:00
parent 5e619bf213
commit 6d01f5085b
2 changed files with 11 additions and 1 deletions

View File

@@ -52,6 +52,10 @@ make_sandbox() {
if [ -n "${master_port}" ]; then
local master_listen_port=$(($master_port + 10))
cluster_address="gcomm://$ip:$master_listen_port"
local this_listen_port=$(($port + 10))
local this_cluster_address="gcomm://$ip:$this_listen_port"
sed -e "s!gcomm://\$!$this_cluster_address!g" -i.bak "/tmp/$master_port/my.sandbox.cnf"
fi
sed -e "s/ADDR/$ip/g" -i.bak "/tmp/$port/my.sandbox.cnf"
@@ -118,7 +122,7 @@ make_sandbox() {
debug_sandbox $port
exit 1
fi
# If the sandbox is a slave, start the slave.
if [ "$type" = "slave" ]; then
/tmp/$port/use -e "change master to master_host='127.0.0.1', master_user='msandbox', master_password='msandbox', master_port=$master_port"

View File

@@ -299,6 +299,12 @@ case $opt in
exit_status=$((exit_status | $?))
if [ "${2:-""}" = "cluster" ]; then
# Bit of magic here. 'start-sandbox cluster new_node old_node'
# changes old_node's my.sandbox.cnf's wsrep_cluster_address to
# point to new_node. This is especially useful because otherwise,
# calling stop/start like below on 12345 would create a new cluster.
/tmp/12345/stop >/dev/null
/tmp/12345/start >/dev/null
echo -n "Checking that the cluster size is correct... "
size=$(/tmp/12345/use -ss -e "SHOW STATUS LIKE 'wsrep_cluster_size'" | awk '{print $2}')
if [ ${size:-0} -ne 3 ]; then