Improve percona cluster initialization
* Switch from /etc/init.d/mysql bootstrap-pxc to /etc/init.d/mysql restart-bootstrap when bootstrapping a new cluster. This ensures that, even when Percona starts at boot, that new config is loaded and the cluster is bootstrapped. * If percona fails to bootstrap or restart, ensure we do not touch the initialized file, allowing os-refresh-config to try again on the next iteration. Co-Authored-By: Gregory Haynes <greg@greghaynes.net> Change-Id: Ia720e40329a1d39db2e25fc917fbf5b5ea85dedc
This commit is contained in:
parent
0c154b6438
commit
60eba01502
@ -12,10 +12,10 @@ if [ ! -e ${MYSQL_INITIALIZED} ]; then
|
|||||||
# Needed to setup initial tables. This command is idempotent.
|
# Needed to setup initial tables. This command is idempotent.
|
||||||
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/mnt/state/var/lib/mysql --no-defaults --pid-file=$pid_path --wsrep-new-cluster
|
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/mnt/state/var/lib/mysql --no-defaults --pid-file=$pid_path --wsrep-new-cluster
|
||||||
|
|
||||||
# We install this init script so we can trust this path exists
|
# We install this init script so we can trust this path exists.
|
||||||
/etc/init.d/mysql bootstrap-pxc
|
# Use of restart-bootstrap vs bootstrap-pxc ensures that, even if
|
||||||
|
# MySQL is running, the bootstrap will succeed.
|
||||||
touch ${MYSQL_INITIALIZED}
|
/etc/init.d/mysql restart-bootstrap
|
||||||
elif [ $? -eq 1 ]; then
|
elif [ $? -eq 1 ]; then
|
||||||
if grep -qE '^wsrep_cluster_address[[:space:]]*=[[:space:]]*gcomm://[[:space:]]*$' /etc/mysql/conf.d/cluster.cnf; then
|
if grep -qE '^wsrep_cluster_address[[:space:]]*=[[:space:]]*gcomm://[[:space:]]*$' /etc/mysql/conf.d/cluster.cnf; then
|
||||||
echo "We are configured as joiner and have no nodes configured for the cluster. Refusing to proceed until cluster nodes are known."
|
echo "We are configured as joiner and have no nodes configured for the cluster. Refusing to proceed until cluster nodes are known."
|
||||||
@ -23,12 +23,23 @@ if [ ! -e ${MYSQL_INITIALIZED} ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
os-svc-restart -n mysql
|
os-svc-restart -n mysql
|
||||||
|
|
||||||
touch ${MYSQL_INITIALIZED}
|
|
||||||
else
|
else
|
||||||
echo "We are neither cluster initializer or joiner. Refusing to bootstrap mysql cluster until role is known."
|
echo "We are neither cluster initializer or joiner. Refusing to bootstrap mysql cluster until role is known."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Ensure we actually have a working database, the Percona init script does not
|
||||||
|
# always exit with a non zero code upon failure.
|
||||||
|
if [ ! -S /var/run/mysqld/mysqld.sock ]; then
|
||||||
|
echo "MySQL Socket missing, is percona running correctly?"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Finally, perform a MySQL "ping". This will succeed even when MySQL returns
|
||||||
|
# an "Access Denied" packet, avoiding the need to provide valid credentials.
|
||||||
|
/usr/local/mysql/bin/mysqladmin ping
|
||||||
|
|
||||||
|
touch ${MYSQL_INITIALIZED}
|
||||||
else
|
else
|
||||||
# For single node setups we can re-bootstrap if were not currently running
|
# For single node setups we can re-bootstrap if were not currently running
|
||||||
# We need to ensure we are bootstrap host to prevent our regex succeeding
|
# We need to ensure we are bootstrap host to prevent our regex succeeding
|
||||||
@ -36,7 +47,7 @@ else
|
|||||||
LOCAL_IP=$(os-apply-config --key local-ipv4 --type netaddress --key-default '')
|
LOCAL_IP=$(os-apply-config --key local-ipv4 --type netaddress --key-default '')
|
||||||
if os-is-bootstrap-host && grep -Eq "^wsrep_cluster_address=gcomm://$LOCAL_IP,?\$" /etc/mysql/conf.d/cluster.cnf; then
|
if os-is-bootstrap-host && grep -Eq "^wsrep_cluster_address=gcomm://$LOCAL_IP,?\$" /etc/mysql/conf.d/cluster.cnf; then
|
||||||
if ! /etc/init.d/mysql status; then
|
if ! /etc/init.d/mysql status; then
|
||||||
/etc/init.d/mysql bootstrap-pxc
|
/etc/init.d/mysql restart-bootstrap
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user