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

Replace master/slave with primary/secondary

parent 6b921bad
Branches
No related tags found
No related merge requests found
##
# Ansible playbook to work on a MySQL Slave DB
#
# https://www.howtoforge.com/how-to-repair-mysql-replication
# SHOW SLAVE STATUS \G;
# STOP SLAVE;
# SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;
# START SLAVE;
# SHOW SLAVE STATUS \G;
#
# On the slave, we maybe should:
# SET GLOBAL slow_query_log = "OFF";
# Ansible playbook to work on a MySQL Secondary DB
---
# file: mysqlslave.yml
# file: mysqlsecondary.yml
- name: Import playbook validate
import_playbook: validate.yml
- name: Skip 1 Replication Item
hosts: "dbserver_mysql-slave"
hosts: "dbserver_mysql_secondary"
become: no
tags:
- skipbyone
tasks:
- name: Stop slave
- name: Stop secondary
mysql_replication:
mode: stopslave
- name: Set Skip Counter
mysql_variables:
variable: sql_slave_skip_counter
value: 1
- name: Start slave
- name: Start secondary
mysql_replication:
mode: startslave
- name: MySQL Replication
hosts: "dbserver_mysql-slave"
hosts: "dbserver_mysql_secondary"
become: no
tags:
- changemaster
......@@ -48,13 +38,13 @@
mode: changemaster
login_host: 127.0.0.1
login_user: root
login_password: root
login_password: '{{ mysql_root_password|default("root") }}'
master_host: 127.0.0.1
master_port: '{{ port }}'
master_user: repl
master_password: repl
master_log_file: '{{ binlog }}'
master_log_pos: '{{ binpos }}'
master_log_file: '{{ binlog|default("/var/log/mysql/mysql-bin.log") }}'
master_log_pos: '{{ binpos|default(0) }}'
- name: Start Replication
mysql_replication:
mode: startslave
......@@ -3,7 +3,7 @@
description: MySQL Slave - Skip counter by 1
cli:
defaults:
limit: dbserver_mysql-slave
limit: dbserver_mysql_secondary
arguments:
playbook: mysqlslave
command:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment