Commit 7cb62aee authored by Fabio Montefuscolo's avatar Fabio Montefuscolo
Browse files

Cluster is now running connected

parent 0db213ac
Pipeline #2950 passed with stage
in 1 minute and 8 seconds
......@@ -57,4 +57,4 @@ EXPOSE 3306 4567 4568
COPY entrypoint /entrypoint
ENTRYPOINT ["/bin/bash", "/entrypoint/main.sh"]
CMD ["/usr/sbin/mysqld", "--user=mysql"]
CMD ["/usr/sbin/mysqld"]
......@@ -31,25 +31,13 @@ then
export CLUSTER_JOIN
fi
IFS=","
latest="-1"
leader=""
online=""
IFS=","
for ip in $CLUSTER_JOIN;
do
if ping -n -c1 -W1 $ip >&-;
then
leader="${leader:-$ip}"
res=$(curl -sS "http://$ip:8888/grastate/seqno")
res="${res:-$latest}"
if [[ "${res}" -gt "$latest" ]];
then
latest="$res"
leader="$ip"
fi
if [ -z "$online" ];
then
online="$ip"
......@@ -64,36 +52,18 @@ IFS="
if [ "$(basename $1)" = "mysqld" ];
then
MYSQLD_ARGS=("--wsrep_cluster_name='$CLUSTER_NAME'")
if [ "$leader" = "$MY_IP" ];
then
if [ "$latest" == "-1" ];
then
sed -i -e '/^safe_to_bootstrap/s/0/1/' "${PXC_DATA}/grastate.dat"
fi
MYSQLD_ARGS+=("--wsrep-new-cluster")
MYSQLD_ARGS+=("--wsrep_cluster_address=gcomm://$MY_IP?pc.wait_prim=no")
else
while ! `echo 1 > /dev/tcp/$leader/3306`;
do
echo "Waiting leader $leader";
sleep 5
done
MYSQLD_ARGS+=("--wsrep_cluster_address='gcomm://$online'")
fi
rm "${MYSQL_LOG_FILE}"
mkfifo -m 777 "${MYSQL_LOG_FILE}"
cat "${MYSQL_LOG_FILE}" &
MYSQLD_ARGS+=("--wsrep_sst_method=xtrabackup-v2")
MYSQLD_ARGS+=("--wsrep_sst_auth='xtrabackup:$XTRABACKUP_PASSWORD'")
MYSQLD_ARGS+=("--wsrep_node_address='$MY_IP'")
echo "$@ $MYSQLD_ARGS" >&2
$@ $MYSQLD_ARGS
set -- "$@" "--user=mysql"
set -- "$@" "--wsrep_cluster_name=$CLUSTER_NAME"
set -- "$@" "--wsrep_sst_method=xtrabackup-v2"
set -- "$@" "--wsrep_cluster_address=gcomm://$online"
set -- "$@" "--wsrep_sst_auth=xtrabackup:$XTRABACKUP_PASSWORD"
set -- "$@" "--wsrep_node_address=$MY_IP"
exec "$@"
else
exec "$@"
fi
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment