Skip to content

Add MySQL v9.0.1 #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: CI

on:
pull_request:
branches:
- "*"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}-ci
cancel-in-progress: true

jobs:
build:
name: Build
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v1

- name: Print version info
id: semver
run: |
make version

- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Build
run: |
make container
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ LABEL org.opencontainers.image.source https://github.com/kubedb/mysql-init-docke
RUN apk add --no-cache bash

COPY scripts /tmp/scripts
RUN chmod +x /tmp/scripts/*.sh
COPY init-script /init-script
COPY --from=0 /tini /tmp/scripts/tini

Expand Down
6 changes: 6 additions & 0 deletions init-script/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@
rm -rf /var/lib/mysql/lost+found
rm -rf /run-scripts/*
cp /tmp/scripts/* /scripts
if [[ "$PITR_RESTORE" == "true" ]]; then
if [[ "$HOSTNAME" != *"-0" ]]; then
rm /var/lib/mysql/auto.cnf
fi
fi

32 changes: 32 additions & 0 deletions scripts/copy-data.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash

ROOT_DIR="$ROOT_DIR"
TOTAL_DIR_TO_COPY="$TOTAL_DIR_TO_COPY"
DATA_DIR="$DATA_DIR"

if [ -z "$ROOT_DIR" ] || [ -z "$TOTAL_DIR_TO_COPY" ]; then
echo "ROOT_DIR and TOTAL_DIR_TO_COPY must be set."
exit 1
fi
Size1=$(du -s "$ROOT_DIR" | cut -f1)
echo "DATA DIRECTORY SIZE: ", $Size1
for (( i = 1; i <= $TOTAL_DIR_TO_COPY; i++ ));do
if [[ -d "$ROOT_DIR$i" ]];then
Size2=$(du -s "$ROOT_DIR$i" | cut -f1)
echo $Size1, " ", $Size2
if [[ "$Size1" == "$Size2" ]];then
continue
fi
fi
# not deleting any data
# because the sole purpose of this script is to copy the data
# rm -rf "$ROOT_DIR$i"/*
rm "$ROOT_DIR/mysql.sock"
cp -rvL "$ROOT_DIR/"* "$ROOT_DIR$i"/
if [[ $? -ne 0 ]]; then
echo "Error occurred while copying to $ROOT_DIR$i"
exit 1
fi
done

exit 0
9 changes: 9 additions & 0 deletions scripts/directory-exist.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

file="/var/lib/mysql/join-in-cluster"

if [ -e "$file" ]; then
echo -n "Not Empty"
else
echo -n "Empty"
fi
59 changes: 59 additions & 0 deletions scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,24 @@
# HOST_ADDRESS_TYPE = Address type of HOST_ADDRESS (one of DNS, IPV4, IPv6)
# POD_IP = IP address used to create whitelist CIDR. For HOST_ADDRESS_TYPE=DNS, it will be status.PodIP.
# POD_IP_TYPE = Address type of POD_IP (one of IPV4, IPv6)
# PRIMARY_TYPE = defines single/multi primary

env | sort | grep "POD\|HOST\|NAME"
RECOVERY_DONE_FILE="/tmp/recovery.done"
if [[ "$PITR_RESTORE" == "true" ]]; then
while true; do
sleep 2
echo "Point In Time Recovery In Progress. Waiting for $RECOVERY_DONE_FILE file"
if [[ -e "$RECOVERY_DONE_FILE" ]]; then
echo "$RECOVERY_DONE_FILE found."
break
fi
done
fi

if [[ -e "$RECOVERY_DONE_FILE" ]]; then
rm $RECOVERY_DONE_FILE
fi

args=$@
script_name=${0##*/}
Expand Down Expand Up @@ -104,6 +120,48 @@ mkdir -p /etc/mysql/group-replication.conf.d/
echo "!includedir /etc/mysql/group-replication.conf.d/" >>/etc/mysql/my.cnf
mkdir -p /etc/mysql/conf.d/
echo "!includedir /etc/mysql/conf.d/" >>/etc/mysql/my.cnf
if [[ "$PRIMARY_TYPE" == "Multi-Primary" ]]; then
cat >>/etc/mysql/group-replication.conf.d/group.cnf <<EOL
[mysqld]
disabled_storage_engines="MyISAM,BLACKHOLE,FEDERATED,ARCHIVE,MEMORY"

# General replication settings
gtid_mode = ON
enforce_gtid_consistency = ON
binlog_checksum = NONE
log_bin = binlog
loose-group_replication_bootstrap_group = OFF
loose-group_replication_start_on_boot = OFF

# default tls configuration for the group
# group_replication_recovery_use_ssl will be overwritten from DB arguments
loose-group_replication_ssl_mode = REQUIRED
loose-group_replication_recovery_use_ssl = 1

# Shared replication group configuration
loose-group_replication_group_name = "${GROUP_NAME}"
#loose-group_replication_ip_whitelist = "${hosts}"
#loose-group_replication_ip_whitelist = "AUTOMATIC"
#loose-group_replication_ip_allowlist = "AUTOMATIC"
loose-group_replication_ip_whitelist = "${whitelist}"
loose-group_replication_ip_allowlist = "${whitelist}"
loose-group_replication_group_seeds = "${seeds}"

# Single or Multi-primary mode? Uncomment these two lines
# for multi-primary mode, where any host can accept writes
loose-group_replication_single_primary_mode = OFF
loose-group_replication_enforce_update_everywhere_checks = ON

# Host specific replication configuration
server_id = ${svr_id}
#bind-address = "${report_host}"
#bind-address = "0.0.0.0"
bind-address = *
report_host = "${report_host}"
loose-group_replication_local_address = "${report_host}:33061"
socket="/var/run/mysqld/mysqld.sock"
EOL
else
cat >>/etc/mysql/group-replication.conf.d/group.cnf <<EOL
[mysqld]
disabled_storage_engines="MyISAM,BLACKHOLE,FEDERATED,ARCHIVE,MEMORY"
Expand Down Expand Up @@ -144,6 +202,7 @@ report_host = "${report_host}"
loose-group_replication_local_address = "${report_host}:33061"
socket="/var/run/mysqld/mysqld.sock"
EOL
fi

# wait for mysql daemon be running (alive)
function wait_for_mysqld_running() {
Expand Down
1 change: 0 additions & 1 deletion scripts/run_innodb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ mkdir -p /etc/mysql/conf.d/
cat >>/etc/mysql/my.cnf <<EOL
!includedir /etc/mysql/conf.d/
[mysqld]
default_authentication_plugin=mysql_native_password
#loose-group_replication_ip_whitelist = "${whitelist}"
loose-group_replication_ip_allowlist = "${whitelist}"
EOL
Expand Down
6 changes: 3 additions & 3 deletions scripts/run_read_only.sh
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,17 @@ function wait_for_mysqld_running() {
function start_read_replica() {
#stop_slave
local mysql="$mysql_header --host=$localhost"
$mysql_header -e "stop slave;"
$mysql_header -e "stop replica;"
ssl_config=",SOURCE_SSL=0"
if [[ "$source_ssl" == "true" ]]; then
ssl_config=",SOURCE_SSL=1,SOURCE_SSL_CA = '/etc/mysql/server/certs/ca.crt',SOURCE_SSL_CERT = '/etc/mysql/server/certs/tls.crt',SOURCE_SSL_KEY = '/etc/mysql/server/certs/tls.key'"
require_SSL="REQUIRE SSL"
fi
echo $ssl_config
out=$($mysql_header -e "CHANGE MASTER TO MASTER_HOST = '$SOURCE_HOST',MASTER_PORT = 3306,MASTER_USER = '$SOURCE_USERNAME',MASTER_PASSWORD = '$SOURCE_PASSWORD',MASTER_AUTO_POSITION = 1 $ssl_config;")
out=$($mysql_header -e "CHANGE REPLICATION SOURCE TO SOURCE_HOST = '$SOURCE_HOST',SOURCE_PORT = 3306,SOURCE_USER = '$SOURCE_USERNAME',SOURCE_PASSWORD = '$SOURCE_PASSWORD',SOURCE_AUTO_POSITION = 1 $ssl_config;")
echo $out
sleep 1
out=$($mysql_header -e "start slave;")
out=$($mysql_header -e "start replica;")
echo $out

$mysql_header -e "set global super_read_only=ON"
Expand Down
6 changes: 3 additions & 3 deletions scripts/run_semi_sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function install_clone_plugin() {
log "INFO" "Clone plugin is not installed. Installing the plugin..."
retry 120 ${mysql} -e "INSTALL PLUGIN clone SONAME 'mysql_clone.so';"
reading_first_time=1
retry 120 ${mysql} -e "reset master;"
retry 120 ${mysql} -e "RESET BINARY LOGS AND GTIDS;"
log "INFO" "Clone plugin successfully installed"
else
log "INFO" "Already clone plugin is installed"
Expand All @@ -90,8 +90,8 @@ function install_semiSync_plugin() {
out=$(${mysql} -N -e 'SHOW PLUGINS;' | grep semisync)
if [[ -z "$out" ]]; then
log "INFO" "semisync plugin is not installed. Installing the plugin..."
retry 120 ${mysql} -e "INSTALL PLUGIN rpl_semi_sync_master SONAME 'semisync_master.so';"
retry 120 ${mysql} -e "INSTALL PLUGIN rpl_semi_sync_slave SONAME 'semisync_slave.so';"
retry 120 ${mysql} -e "INSTALL PLUGIN rpl_semi_sync_source SONAME 'semisync_source.so';"
retry 120 ${mysql} -e "INSTALL PLUGIN rpl_semi_sync_replica SONAME 'semisync_replica.so';"
reading_first_time=1
log "INFO" "semi_sync plugin successfully installed"
else
Expand Down
19 changes: 19 additions & 0 deletions scripts/standalone-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

if [[ -z "$TOPOLOGY" ]]; then
RECOVERY_DONE_FILE="/tmp/recovery.done"
if [[ "$PITR_RESTORE" == "true" ]]; then
while true; do
sleep 2
echo "Point In Time Recovery In Progress. Waiting for $RECOVERY_DONE_FILE file"
if [[ -e "$RECOVERY_DONE_FILE" ]]; then
echo "$RECOVERY_DONE_FILE found."
break
fi
done
fi

if [[ -e "$RECOVERY_DONE_FILE" ]]; then
rm $RECOVERY_DONE_FILE
fi
fi
Loading