fix: apply mysql host config after package defaults
This commit is contained in:
parent
b8fabe9fa0
commit
4d36ab64c8
29
ops/110-native-mysql/apply-replica-config.sh
Executable file
29
ops/110-native-mysql/apply-replica-config.sh
Executable file
@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
if [[ $EUID -ne 0 || $# -ne 1 ]]; then
|
||||
echo "usage: sudo $0 <mysql-config.cnf>" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
config_file=$(realpath "$1")
|
||||
config_target=/etc/mysql/mysql.conf.d/99-mes-prd.cnf
|
||||
if [[ ! -s $config_file ]]; then
|
||||
echo "config file is missing or empty: $config_file" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if ! dpkg-query -W mysql-server-8.0 >/dev/null 2>&1; then
|
||||
echo "mysql-server-8.0 is not installed" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mysqld --defaults-file="$config_file" --validate-config
|
||||
if [[ -e $config_target ]]; then
|
||||
unlink "$config_target"
|
||||
fi
|
||||
install -m 0644 "$config_file" "$config_target"
|
||||
systemctl restart mysql
|
||||
systemctl is-active --quiet mysql
|
||||
mysql --batch --skip-column-names -e \
|
||||
"SELECT @@version, @@server_id, @@bind_address, @@lower_case_table_names, @@read_only, @@super_read_only, @@gtid_mode"
|
||||
@ -7,6 +7,7 @@ if [[ $EUID -ne 0 || $# -ne 1 ]]; then
|
||||
fi
|
||||
|
||||
config_file=$(realpath "$1")
|
||||
config_target=/etc/mysql/mysql.conf.d/99-mes-prd.cnf
|
||||
if [[ ! -s $config_file ]]; then
|
||||
echo "config file is missing or empty: $config_file" >&2
|
||||
exit 2
|
||||
@ -31,12 +32,7 @@ apt-get update
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-common
|
||||
install -d -m 0755 /etc/mysql/mysql.conf.d
|
||||
sed -e '/^read_only=/d' -e '/^super_read_only=/d' "$config_file" \
|
||||
> /etc/mysql/mysql.conf.d/99-mes-prd.cnf
|
||||
chmod 0644 /etc/mysql/mysql.conf.d/99-mes-prd.cnf
|
||||
> "$config_target"
|
||||
chmod 0644 "$config_target"
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server
|
||||
install -m 0644 "$config_file" /etc/mysql/mysql.conf.d/99-mes-prd.cnf
|
||||
systemctl restart mysql
|
||||
|
||||
systemctl is-active --quiet mysql
|
||||
mysql --batch --skip-column-names -e \
|
||||
"SELECT @@version, @@server_id, @@lower_case_table_names, @@read_only, @@super_read_only, @@gtid_mode"
|
||||
"$(dirname "$(realpath "$0")")/apply-replica-config.sh" "$config_file"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user