Browse Source

Merge branch 'master' of git.osuv.de:m/dotfiles

master
Markus Bergholz 1 year ago
parent
commit
81d793c579
1 changed files with 24 additions and 7 deletions
  1. +24
    -7
      docker/mariadb/10.3.17/README.md

+ 24
- 7
docker/mariadb/10.3.17/README.md View File

@ -35,13 +35,23 @@ docker exec -ti mariadb mysql_upgrade
# create replica from writer node
1. dump
#### 1. create replica user
```sql
CREATE USER 'repl'@'%' IDENTIFIED BY 'repl';
GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%';
```
#### 2. dump
```
docker exec -ti mariadb mysqldump --master-data=1 --single-transaction --flush-privileges --routines --triggers --all-databases > writer_dump.sql
```
and mv `writer_dump.sql` into volume/mount of read replica.
#### 3. create read replica
grep informations about bin log position
```
@ -49,17 +59,15 @@ grep "CHANGE MASTER TO MASTER_LOG_FILE" data/writer_dump.sql |head -n 1
CHANGE MASTER TO MASTER_LOG_FILE='77abd7ecc317-bin.000001', MASTER_LOG_POS=39867;
```
2. start read replica
start read replica
```
docker run -d --rm -v $(pwd)/data:/var/lib/mysql/ --name mariadb-ro -e READ_ONLY="--read-only" --network db -e SERVER_ID=10 -p 127.0.0.1:3310:3306 markuman/mariadb:alpine-10.3.18.0
```
3. prepare replica
jump into container and apply dump
```
```sql
mysql < writer_dump.sql
mysql
@ -72,9 +80,18 @@ MASTER_LOG_FILE='77abd7ecc317-bin.000001',
MASTER_LOG_POS=39867,
MASTER_CONNECT_RETRY=10;
start slave
start slave;
```
and you're done.
check with `SHOW SLAVE STATUS \G`
check with `SHOW SLAVE STATUS \G`
# proxysql
create `monitor` user for proxysql
```sql
CREATE USER 'monitor'@'%' IDENTIFIED BY 'monitor';
GRANT SELECT on sys.* to 'monitor'@'%';
```

Loading…
Cancel
Save