Browse Source

add notes about mariadb read replica

master
Markus Bergholz 2 years ago
parent
commit
46619655e5
  1. 35
      til.md

35
til.md

@ -528,3 +528,38 @@ mount with zstd compression
grow / resize btrfs partition
`sudo btrfs filesystem resize +3g /mnt/backup`
# MariaDB replica
use rsync - everything else sucks!
if you can't use rsync, you must lock all tables and use mysqldump.
```
# on mariadb writer instance
rsync -Sa --progress --delete /var/lib/mysql/ root@target_replica_host:/var/lib/mysql/
mysql> flush tables with read lock;
mysql> show master status;
rsync -Sa --progress --delete /var/lib/mysql/ root@target_replica_host:/var/lib/mysql/
mysql> unlock tables;
mysql> CREATE USER 'repl'@'%' IDENTIFIED BY 'repl';
mysql> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%';
# on new mariadb reader replica
# start with server_id != 1
CHANGE MASTER TO
MASTER_HOST='mariadb_writer_host',
MASTER_USER='repl',
MASTER_PASSWORD='repl',
MASTER_PORT=3306,
MASTER_LOG_FILE='83e8e184d773-bin.000001',
MASTER_LOG_POS=335,
MASTER_CONNECT_RETRY=10;
// MASTER_USE_GTID = slave_pos # for GTID
start slave;
```
Loading…
Cancel
Save