Skip to content
Snippets Groups Projects
Commit 03b6a4d9 authored by jurgenhaas's avatar jurgenhaas
Browse files

Update mysql replication setup

parent 5a314356
No related branches found
No related tags found
No related merge requests found
Pipeline #36011 passed
......@@ -43,7 +43,7 @@ drupal_settings:
- access*
```
# Replcation
# Replication
- [Replication Configuration](https://dev.mysql.com/doc/refman/5.7/en/replication.html)
- [Replication SQL Statements](https://dev.mysql.com/doc/refman/5.7/en/sql-replication-statements.html)
......@@ -54,6 +54,43 @@ Starting from [here](https://dev.mysql.com/doc/refman/5.7/en/replication-howto-m
- Create a DB dump: lock tables, remember bin log position, dump db (see [Choosing a Method for Data Snapshots](https://dev.mysql.com/doc/refman/5.7/en/replication-snapshot-method.html)) and copy to secondary host
- Unlock the tables again
- Configure secondary for new master with Ansible playbook `dans COMPANY mysqlsecondary --tags=changemaster --extra-vars="port=[PORT]" --extra-vars="binpos=[BINLOGPOS]"`
- On the secondary, start the MySQL server and turn off replication (`stop slave`)
- Import dump file and then start replication again (`start slave`)
- Configure secondary for new master with Ansible playbook
- On the secondary, start the MySQL server and turn off replication
- Import dump file and then start replication again
**On the primary:**
```mysql
FLUSH TABLES WITH READ LOCK;
SHOW MASTER STATUS;
```
**On the primary in a second shell:**
```shell
mysqldump --all-databases --master-data > dbdump.db
scp dbdump.db >[SECONDARY]:
```
**On the primary:**
```mysql
UNLOCK TABLES;
```
**With Ansible:**
```shell
apb mysqlsecondary --company=[COMPANY] --tags=changemaster --extra-vars="port=[PORT]" --extra-vars="binpos=[BINPOS]" --extra-vars="binlog=/var/log/mysql/[BINPOS]"
```
**On the secondary:**
```shell
mysql < dbdump.db
```
```mysql
START SLAVE;
SHOW SLAVE STATUS;
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment