fixed check of mysqld daemon if it is up. When config is not yet confirmed by all management servers, the mysqld could not start.
This commit is contained in:
@@ -42,32 +42,32 @@ else
|
||||
chown -R $(id -u):$(id -g) /usr/mysql-cluster
|
||||
chown -R $(id -u):$(id -g) /var/run/mysqld
|
||||
fi
|
||||
|
||||
|
||||
|
||||
if [[ ! -z "${MYSQL_DAEMON_USER}" ]]; then
|
||||
if [[ ( "${MYSQLD_CLUSTER}" = "true" ) ]]; then
|
||||
runuser -u ${MYSQL_DAEMON_USER} -- $@ --socket=/tmp/mysql.sock --bind-address=0.0.0.0 &
|
||||
start_process () {
|
||||
if [[ ! -z "${MYSQL_DAEMON_USER}" ]]; then
|
||||
if [[ ( "${MYSQLD_CLUSTER}" = "true" ) ]]; then
|
||||
runuser -u ${MYSQL_DAEMON_USER} -- $@ --socket=/tmp/mysql.sock --bind-address=0.0.0.0 &
|
||||
else
|
||||
runuser -u ${MYSQL_DAEMON_USER} -- $@ &
|
||||
fi
|
||||
else
|
||||
runuser -u ${MYSQL_DAEMON_USER} -- $@ &
|
||||
if [[ ( "${MYSQLD_CLUSTER}" = "true" ) ]]; then
|
||||
sed -i "s/.*user=.*/user=root/" /etc/my.cnf #needed to change the user option otherwise mysqld doesn't start in root mode
|
||||
$@ --user=root --socket=/tmp/mysql.sock -bind-address=0.0.0.0 &
|
||||
else
|
||||
$@ &
|
||||
fi
|
||||
fi
|
||||
else
|
||||
if [[ ( "${MYSQLD_CLUSTER}" = "true" ) ]]; then
|
||||
sed -i "s/.*user=.*/user=root/" /etc/my.cnf #needed to change the user option otherwise mysqld doesn't start in root mode
|
||||
$@ --user=root --socket=/tmp/mysql.sock -bind-address=0.0.0.0 &
|
||||
else
|
||||
$@ &
|
||||
fi
|
||||
fi
|
||||
}
|
||||
echo "Starting process. Sleeping 15 sec before continuing"
|
||||
start_process $@
|
||||
sleep 15
|
||||
|
||||
if [[ -z "${MYSQLD_CLUSTER_NOPASS}" ]]; then
|
||||
MYSQLD_CLUSTER_NOPASS="false"
|
||||
fi
|
||||
|
||||
|
||||
if [[ ($DBEXIST -eq 0) && ( "${MYSQLD_CLUSTER}" = "true" ) && ( "${MYSQLD_CLUSTER_NOPASS}" = "false" )]]; then
|
||||
|
||||
sleep 10
|
||||
|
||||
echo "Trying to set DB Root Password"
|
||||
MYSQLSTARTED=0
|
||||
@@ -86,6 +86,14 @@ if [[ ($DBEXIST -eq 0) && ( "${MYSQLD_CLUSTER}" = "true" ) && ( "${MYSQLD_CLUS
|
||||
|
||||
while [[ $MYSQLSTARTED -eq 0 ]]
|
||||
do
|
||||
#mysqld could not start because config need to be confirmed by management servers
|
||||
while [[ -z $(ps -e | grep mysqld) ]]
|
||||
do
|
||||
echo "Starting process again. Sleeping 15 sec before continuing"
|
||||
start_process $@
|
||||
sleep 15
|
||||
done
|
||||
|
||||
RESULT=""
|
||||
|
||||
mysql -u root -e "CREATE USER 'root'@'%' IDENTIFIED BY '${PASSWORD}';GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';" --socket=/tmp/mysql.sock
|
||||
|
||||
Reference in New Issue
Block a user