Browse Source

update README

master
Markus Bergholz 1 year ago
parent
commit
bdc2859aa7
1 changed files with 14 additions and 6 deletions
  1. +14
    -6
      docker/mariadb/10.3.17/README.md

+ 14
- 6
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,7 +80,7 @@ MASTER_LOG_FILE='77abd7ecc317-bin.000001',
MASTER_LOG_POS=39867,
MASTER_CONNECT_RETRY=10;
start slave
start slave;
```
and you're done.


Loading…
Cancel
Save