This commit is contained in:
2023-04-16 21:38:32 +08:00
parent a0849e40ef
commit 0b6c876a0f
59 changed files with 1026 additions and 189 deletions

View File

@@ -62,7 +62,7 @@ function ProbeSeeds {
[ "$all_seeds" = "$other_seeds" ] \
&& Print Not found local_address in group_seeds! \
&& exit 1
Print Probe connection to other seeds ...
Print Probing connection to other seeds ...
for seed in $other_seeds; do
echo -n "Connecting $seed ... "
curl -s --connect-timeout 8 ftp://$seed || seed_return=$?
@@ -76,10 +76,10 @@ function ProbeSeeds {
function Init {
rm -f ${SOCK_FILE}* ${PID_FILE}
chown -R mysql.mysql $LOG_DIR $BINLOG_DIR $DATA_DIR
chown -R mysql:mysql $LOG_DIR $BINLOG_DIR $DATA_DIR
if [ ! -d "$DATA_DIR/mysql" ]; then
Print Write essential server config to /etc/mysql/my.cnf ...
Print Init mysql db files ...
Print Writing essential server config to /etc/mysql/my.cnf ...
Print Initing mysql db files ...
mysqld_pre_systemd
INIT_FLAG=1
fi
@@ -87,7 +87,7 @@ function Init {
function InitGroupReplication {
if ! grep -i '^group[-_]replication' /etc/my.cnf; then
Print Write advisable group replication config to /etc/my.cnf ...
Print Writing advisable group replication config to /etc/my.cnf ...
grep -i '^binlog[-_]expire[-_]logs[-_]seconds' /etc/my.cnf \
|| echo 'binlog-expire-logs-seconds = 172800' >> /etc/my.cnf
echo 'group-replication-consistency = BEFORE_ON_PRIMARY_FAILOVER
@@ -98,7 +98,7 @@ group-replication-exit-state-action = OFFLINE_MODE
' >> /etc/my.cnf
fi
if ! grep -i '^group[-_]replication' /etc/mysql/my.cnf; then
Print Write essential group replication config to /etc/mysql/my.cnf ...
Print Writing essential group replication config to /etc/mysql/my.cnf ...
cat >> /etc/mysql/my.cnf <<-EOF
server-id = $SERVER_ID
gtid-mode = ON
@@ -127,7 +127,7 @@ function ImportInitSql {
mysql -e "CREATE USER docker@localhost IDENTIFIED BY 'China_19\$(10)!'"
mysql -e "GRANT SHUTDOWN ON *.* TO docker@localhost"
if sql_files="$(ls $LOG_DIR/init_sql/*.sql 2>/dev/null)"; then
Print Import the sql files ...
Print Importing the sql files ...
for sql_file in $sql_files; do
Print Importing $sql_file ...
mysql < $sql_file
@@ -138,20 +138,20 @@ function ImportInitSql {
function StartGroupReplication {
if [ -n "$BOOTSTRAP_GROUP" ]; then
Print Bootstrap new group replication ...
Print Bootstraping new group replication ...
mysql -e "
SET GLOBAL group_replication_bootstrap_group=ON;
START GROUP_REPLICATION;
SET GLOBAL group_replication_bootstrap_group=OFF;
"
else
Print Join a running group replication ...
Print Joining a running group replication ...
mysql -e "START GROUP_REPLICATION;"
fi
}
function CreateGroupReplicationChannel {
Print Create user and channel of group replication ...
Print Creating user and channel of group replication ...
mysql -e "SET SQL_LOG_BIN=0;
CREATE USER rpl@'%' IDENTIFIED BY 'Rpl_1234';
GRANT REPLICATION SLAVE ON *.* TO rpl@'%';
@@ -166,7 +166,7 @@ function CreateGroupReplicationChannel {
}
function StartExtraScripts {
Print Start extra scripts ...
Print Starting extra scripts ...
while sleep 2; do
for script in $(find $LOG_DIR/extra_scripts/ -type f -executable \
2>/dev/null || true); do
@@ -176,7 +176,7 @@ function StartExtraScripts {
}
function StartProc {
Print Start mysql ...
Print Starting mysql ...
mysqld -u mysql &
PIDS="$PIDS $!"
while sleep 1; do