deploy: add native mysql replicas for 110
This commit is contained in:
parent
d34b78c40e
commit
b8fabe9fa0
29
ops/110-native-mysql/99-mes-prd-replica-13.cnf
Normal file
29
ops/110-native-mysql/99-mes-prd-replica-13.cnf
Normal file
@ -0,0 +1,29 @@
|
||||
[mysqld]
|
||||
server-id=11013
|
||||
bind-address=0.0.0.0
|
||||
mysqlx-bind-address=127.0.0.1
|
||||
port=3306
|
||||
datadir=/var/lib/mysql
|
||||
socket=/var/run/mysqld/mysqld.sock
|
||||
lower_case_table_names=1
|
||||
log-bin=mysql-bin
|
||||
binlog_format=ROW
|
||||
gtid_mode=ON
|
||||
enforce_gtid_consistency=ON
|
||||
log_replica_updates=ON
|
||||
relay_log=relay-bin
|
||||
relay_log_recovery=ON
|
||||
binlog_expire_logs_seconds=604800
|
||||
sync_binlog=1
|
||||
innodb_flush_log_at_trx_commit=1
|
||||
innodb_buffer_pool_size=8G
|
||||
max_connections=1000
|
||||
character-set-server=utf8mb4
|
||||
collation-server=utf8mb4_0900_ai_ci
|
||||
default-time-zone='+8:00'
|
||||
slow_query_log=ON
|
||||
slow_query_log_file=/var/log/mysql/mysql-slow.log
|
||||
long_query_time=2
|
||||
skip_name_resolve=ON
|
||||
read_only=ON
|
||||
super_read_only=ON
|
||||
29
ops/110-native-mysql/99-mes-prd-replica-64.cnf
Normal file
29
ops/110-native-mysql/99-mes-prd-replica-64.cnf
Normal file
@ -0,0 +1,29 @@
|
||||
[mysqld]
|
||||
server-id=11064
|
||||
bind-address=0.0.0.0
|
||||
mysqlx-bind-address=127.0.0.1
|
||||
port=3306
|
||||
datadir=/var/lib/mysql
|
||||
socket=/var/run/mysqld/mysqld.sock
|
||||
lower_case_table_names=1
|
||||
log-bin=mysql-bin
|
||||
binlog_format=ROW
|
||||
gtid_mode=ON
|
||||
enforce_gtid_consistency=ON
|
||||
log_replica_updates=ON
|
||||
relay_log=relay-bin
|
||||
relay_log_recovery=ON
|
||||
binlog_expire_logs_seconds=604800
|
||||
sync_binlog=1
|
||||
innodb_flush_log_at_trx_commit=1
|
||||
innodb_buffer_pool_size=4G
|
||||
max_connections=1000
|
||||
character-set-server=utf8mb4
|
||||
collation-server=utf8mb4_0900_ai_ci
|
||||
default-time-zone='+8:00'
|
||||
slow_query_log=ON
|
||||
slow_query_log_file=/var/log/mysql/mysql-slow.log
|
||||
long_query_time=2
|
||||
skip_name_resolve=ON
|
||||
read_only=ON
|
||||
super_read_only=ON
|
||||
29
ops/110-native-mysql/99-mes-prd-replica-73.cnf
Normal file
29
ops/110-native-mysql/99-mes-prd-replica-73.cnf
Normal file
@ -0,0 +1,29 @@
|
||||
[mysqld]
|
||||
server-id=11073
|
||||
bind-address=0.0.0.0
|
||||
mysqlx-bind-address=127.0.0.1
|
||||
port=3306
|
||||
datadir=/var/lib/mysql
|
||||
socket=/var/run/mysqld/mysqld.sock
|
||||
lower_case_table_names=1
|
||||
log-bin=mysql-bin
|
||||
binlog_format=ROW
|
||||
gtid_mode=ON
|
||||
enforce_gtid_consistency=ON
|
||||
log_replica_updates=ON
|
||||
relay_log=relay-bin
|
||||
relay_log_recovery=ON
|
||||
binlog_expire_logs_seconds=604800
|
||||
sync_binlog=1
|
||||
innodb_flush_log_at_trx_commit=1
|
||||
innodb_buffer_pool_size=8G
|
||||
max_connections=1000
|
||||
character-set-server=utf8mb4
|
||||
collation-server=utf8mb4_0900_ai_ci
|
||||
default-time-zone='+8:00'
|
||||
slow_query_log=ON
|
||||
slow_query_log_file=/var/log/mysql/mysql-slow.log
|
||||
long_query_time=2
|
||||
skip_name_resolve=ON
|
||||
read_only=ON
|
||||
super_read_only=ON
|
||||
58
ops/110-native-mysql/README.md
Normal file
58
ops/110-native-mysql/README.md
Normal file
@ -0,0 +1,58 @@
|
||||
# 110 native MySQL replicas
|
||||
|
||||
This directory tracks the host-level MySQL replica configuration for the
|
||||
`10.10.11.110` production cluster. MySQL runs under systemd on the worker
|
||||
hosts; it is not deployed as a container.
|
||||
|
||||
## Topology
|
||||
|
||||
| Role | Host | MySQL port | Server ID |
|
||||
| --- | --- | --- | --- |
|
||||
| Existing source | `192.168.110.208` | `3316` | `10` |
|
||||
| Reader 1 | `192.168.110.73` | `3306` | `11073` |
|
||||
| Reader 2 | `192.168.110.13` | `3306` | `11013` |
|
||||
| Backup replica | `192.168.110.64` | `3306` | `11064` |
|
||||
|
||||
ProxySQL is deployed separately as two Kubernetes replicas, following the
|
||||
same pattern as the `10.10.11.10` cluster. The existing source remains the
|
||||
only writer until all replicas pass validation and a separate cutover is
|
||||
approved.
|
||||
|
||||
## Deployment order
|
||||
|
||||
1. Install and seed `.73`, then verify GTID replication and read-only mode.
|
||||
2. Install `.13` and clone it from `.73`, then configure its own GTID channel.
|
||||
3. Install `.64` only after confirming sufficient disk headroom; keep it out
|
||||
of the ProxySQL reader pool as the backup replica.
|
||||
4. Deploy ProxySQL canary and validate routing before changing application
|
||||
traffic.
|
||||
|
||||
The source is MySQL 8.0.32 while Ubuntu 24.04 installs MySQL 8.0.46. Seed the
|
||||
first replica with one online, consistent logical export, then use the clone
|
||||
plugin only between the 8.0.46 replicas.
|
||||
|
||||
Never stop, reset, reinitialize, or change read-only state on the existing
|
||||
source as part of this procedure. Credentials and generated SQL must remain
|
||||
outside Git.
|
||||
|
||||
## Installation
|
||||
|
||||
Run on the target host from a checked-out, pushed revision:
|
||||
|
||||
```bash
|
||||
sudo ./install-replica.sh ./99-mes-prd-replica-73.cnf
|
||||
```
|
||||
|
||||
After seeding and configuring replication, require all of the following:
|
||||
|
||||
```sql
|
||||
SELECT @@server_id, @@read_only, @@super_read_only, @@gtid_mode;
|
||||
SELECT CHANNEL_NAME, SERVICE_STATE, LAST_ERROR_NUMBER, LAST_ERROR_MESSAGE
|
||||
FROM performance_schema.replication_connection_status;
|
||||
SELECT CHANNEL_NAME, SERVICE_STATE
|
||||
FROM performance_schema.replication_applier_status;
|
||||
```
|
||||
|
||||
Both replication service states must be `ON`, both read-only values must be
|
||||
`1`, and the connection error number must be `0` before ProxySQL can use the
|
||||
host.
|
||||
42
ops/110-native-mysql/install-replica.sh
Executable file
42
ops/110-native-mysql/install-replica.sh
Executable file
@ -0,0 +1,42 @@
|
||||
#!/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")
|
||||
if [[ ! -s $config_file ]]; then
|
||||
echo "config file is missing or empty: $config_file" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if pgrep -x mysqld >/dev/null; then
|
||||
echo "mysqld is already running; refusing to modify this host" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ss -ltnH 'sport = :3306' | grep -q .; then
|
||||
echo "TCP port 3306 is already in use; refusing to continue" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if dpkg-query -W mysql-server-8.0 >/dev/null 2>&1; then
|
||||
echo "mysql-server-8.0 is already installed; refusing to reinitialize it" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
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
|
||||
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"
|
||||
Loading…
Reference in New Issue
Block a user