feat: mysql replica documentation improvement
This commit is contained in:
parent
7261929a16
commit
71396f37c7
1 changed files with 71 additions and 19 deletions
|
|
@ -14,12 +14,22 @@ MariaDB:
|
|||
|
||||
```shell
|
||||
[mysqld]
|
||||
|
||||
# server identification
|
||||
server-id = 1
|
||||
|
||||
# network
|
||||
bind-address = 0.0.0.0
|
||||
|
||||
# gtid configuration
|
||||
gtid_strict_mode = 1
|
||||
|
||||
# binary logging
|
||||
log-bin = /var/log/mysql/mysql-bin.log
|
||||
binlog-format = ROW
|
||||
binlog-do-db = databeast
|
||||
bind-address = 0.0.0.0
|
||||
gtid_strict_mode = 1
|
||||
|
||||
# replication configuration
|
||||
log_slave_updates = 1
|
||||
```
|
||||
|
||||
|
|
@ -27,13 +37,24 @@ MySQL:
|
|||
|
||||
```shell
|
||||
[mysqld]
|
||||
|
||||
# server identification
|
||||
server-id = 1
|
||||
log_bin = /var/lib/mysql/mysql-bin.log
|
||||
binlog_format = ROW
|
||||
binlog-expire-logs-seconds = 172800
|
||||
max_binlog_size = 100M
|
||||
|
||||
# network
|
||||
bind-address = 0.0.0.0
|
||||
|
||||
# gtid configuration
|
||||
gtid_mode = ON
|
||||
enforce_gtid_consistency = ON
|
||||
|
||||
# binary logging
|
||||
log_bin = /var/lib/mysql/mysql-bin.log
|
||||
binlog_format = ROW
|
||||
max_binlog_size = 100M
|
||||
binlog-expire-logs-seconds = 172800
|
||||
|
||||
# replication configuration
|
||||
log_slave_updates = 1
|
||||
```
|
||||
|
||||
|
|
@ -58,13 +79,13 @@ FLUSH PRIVILEGES;
|
|||
MariaDB:
|
||||
|
||||
```shell
|
||||
mariadb-dump -u root -psupersecuresource --single-transaction --gtid --master-data=1 --databases databeast > /tmp/databeast.sql
|
||||
mariadb-dump -u root -psupersecuresource --single-transaction --gtid --databases databeast > /tmp/databeast.sql
|
||||
```
|
||||
|
||||
MySQL:
|
||||
|
||||
```shell
|
||||
mysqldump -u root -psupersecuresource --single-transaction --set-gtid-purged=ON --source-data=1 --databases databeast > /tmp/databeast.sql
|
||||
mysqldump -u root -psupersecuresource --single-transaction --set-gtid-purged=ON --source-data=2 --databases databeast > /tmp/databeast.sql
|
||||
```
|
||||
|
||||
## Configure replicate
|
||||
|
|
@ -79,33 +100,64 @@ MariaDB:
|
|||
|
||||
```shell
|
||||
[mysqld]
|
||||
|
||||
# server identification
|
||||
server-id = 2
|
||||
read-only = 1
|
||||
relay-log = /var/log/mysql/mysql-relay-bin
|
||||
|
||||
# network
|
||||
bind-address = 0.0.0.0
|
||||
|
||||
# gtid configuration
|
||||
gtid_strict_mode = 1
|
||||
|
||||
# binary logging
|
||||
log-bin = /var/log/mysql/mysql-bin.log
|
||||
binlog-format = ROW
|
||||
bind-address = 0.0.0.0
|
||||
gtid_strict_mode = 1
|
||||
|
||||
# replication configuration
|
||||
log_slave_updates = 1
|
||||
relay-log = /var/log/mysql/mysql-relay-bin
|
||||
|
||||
# parallel replication
|
||||
slave_parallel_mode = optimistic
|
||||
slave_parallel_threads = 2
|
||||
|
||||
# read-only replica
|
||||
read-only = 1
|
||||
```
|
||||
|
||||
MySQL:
|
||||
|
||||
```shell
|
||||
[mysqld]
|
||||
|
||||
# server identification
|
||||
server-id = 2
|
||||
relay_log = /var/lib/mysql/mysql-relay-bin
|
||||
read_only = 1
|
||||
replicate-do-db = databeast
|
||||
log_bin = /var/lib/mysql/mysql-bin.log
|
||||
binlog_format = ROW
|
||||
binlog-expire-logs-seconds = 172800
|
||||
max_binlog_size = 100M
|
||||
|
||||
# network
|
||||
bind-address = 0.0.0.0
|
||||
|
||||
# gtid configuration
|
||||
gtid_mode = ON
|
||||
enforce_gtid_consistency = ON
|
||||
|
||||
# binary logging
|
||||
log_bin = /var/lib/mysql/mysql-bin.log
|
||||
binlog_format = ROW
|
||||
max_binlog_size = 100M
|
||||
binlog-expire-logs-seconds = 172800
|
||||
|
||||
# replication configuration
|
||||
log_slave_updates = 1
|
||||
slave_parallel_type = 'LOGICAL_CLOCK'
|
||||
relay_log = /var/lib/mysql/mysql-relay-bin
|
||||
replicate-do-db = databeast
|
||||
|
||||
# parallel replication
|
||||
slave_parallel_type = LOGICAL_CLOCK
|
||||
slave_parallel_workers = 2
|
||||
|
||||
# read-only replica
|
||||
read_only = 1
|
||||
```
|
||||
|
||||
Restart mariadb: `systemctl restart mariadb`
|
||||
|
|
@ -187,7 +239,7 @@ mysql -u root -p
|
|||
```
|
||||
|
||||
```shell
|
||||
SHOW REPLICA STATUS\G
|
||||
SHOW SLAVE STATUS\G
|
||||
*************************** 1. row ***************************
|
||||
Slave_IO_State: Waiting for master to send event
|
||||
Master_Host: source.example.com
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue