Remove slave statement when possible
See: https://jira.mariadb.org/browse/MDEV-18777
This commit is contained in:
parent
cd0ea2011e
commit
d1cdf270c6
|
|
@ -13,7 +13,7 @@ env:
|
|||
|
||||
before_install:
|
||||
- |
|
||||
if ! git diff --name-only $TRAVIS_COMMIT_RANGE | grep -qvE '(.md)|(.pdf)'
|
||||
if ! git diff --name-only HEAD^ | grep -vE '(.md)|(.pdf)'
|
||||
then
|
||||
echo "Only doc files were updated, not running the CI."
|
||||
exit
|
||||
|
|
|
|||
10
README.md
10
README.md
|
|
@ -6,7 +6,7 @@ Install and configure MariaDB Server on Debian/Ubuntu.
|
|||
|
||||
Optionally, this role also permits one to:
|
||||
|
||||
- deploy a master/slave cluster;
|
||||
- deploy a master/replica cluster;
|
||||
- setup backups and rotation of the dumps.
|
||||
|
||||
## Requirements
|
||||
|
|
@ -175,9 +175,9 @@ See: <https://docs.ansible.com/ansible/latest/modules/mysql_user_module.html>
|
|||
### Replication (optional)
|
||||
|
||||
Replication is only enabled if `mariadb_replication_role` has a value (`master` or
|
||||
`slave`).
|
||||
`replica`).
|
||||
|
||||
The replication setup on the slave use the GTID autopositioning
|
||||
The replication setup on the replica use the GTID autopositioning
|
||||
`master_use_gtid=slave_pos`. See:
|
||||
<https://mariadb.com/kb/en/library/change-master-to/#master_use_gtid>
|
||||
|
||||
|
|
@ -185,11 +185,11 @@ For the moment, we use an `SQL` command but in ansible 2.10, we should be able
|
|||
to use the
|
||||
[`mysql_replication`](https://docs.ansible.com/ansible/latest/modules/mysql_replication_module.html)
|
||||
module (see
|
||||
[`tasks/replication_slave.yml`](./tasks/replication_slave.yml#L09-L33) and
|
||||
[`tasks/replication_replica.yml`](./tasks/replication_replica.yml#L09-L33) and
|
||||
<https://github.com/ansible/ansible/pull/62648>).
|
||||
|
||||
```yaml
|
||||
mariadb_replication_role: "" # master|slave
|
||||
mariadb_replication_role: "" # master|replica
|
||||
mariadb_replication_master_ip: ""
|
||||
mariadb_server_id: "1"
|
||||
mariadb_max_binlog_size: "100M"
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ mariadb_users: []
|
|||
|
||||
# Replication
|
||||
# replication is only enabled if mariadb_replication_role has values
|
||||
mariadb_replication_role: "" # master|slave
|
||||
mariadb_replication_role: "" # master|replica
|
||||
mariadb_replication_master_ip: ""
|
||||
mariadb_max_binlog_size: "100M"
|
||||
mariadb_binlog_format: "MIXED"
|
||||
|
|
|
|||
|
|
@ -9,23 +9,23 @@
|
|||
include_tasks: databases.yml
|
||||
when:
|
||||
- mariadb_databases is defined
|
||||
- mariadb_replication_role != "slave"
|
||||
- mariadb_replication_role != "replica"
|
||||
|
||||
- name: include task users.yml
|
||||
include_tasks: users.yml
|
||||
when:
|
||||
- mariadb_users is defined
|
||||
- mariadb_replication_role != "slave"
|
||||
- mariadb_replication_role != "replica"
|
||||
|
||||
- name: include task replication_master.yml
|
||||
include_tasks: replication_master.yml
|
||||
when: mariadb_replication_role == "master"
|
||||
|
||||
- name: include task replication_slave.yml
|
||||
include_tasks: replication_slave.yml
|
||||
- name: include task replication_replica.yml
|
||||
include_tasks: replication_replica.yml
|
||||
when:
|
||||
- not ansible_check_mode
|
||||
- mariadb_replication_role == "slave"
|
||||
- mariadb_replication_role == "replica"
|
||||
|
||||
- name: include task backup.yml
|
||||
include_tasks: backup.yml
|
||||
|
|
|
|||
|
|
@ -1,25 +1,25 @@
|
|||
---
|
||||
- name: Check slave replication status
|
||||
- name: Check replica replication status
|
||||
mysql_replication:
|
||||
mode: getslave
|
||||
login_unix_socket: "{{ mariadb_unix_socket }}"
|
||||
register: slave
|
||||
register: replica
|
||||
no_log: true
|
||||
|
||||
# For the moment, we have to use a sql command.
|
||||
# In ansible 2.10, we should be able to use mysql_replication module.
|
||||
# See https://github.com/ansible/ansible/pull/62648 (and below)
|
||||
- name: Configure replication on the slave
|
||||
- name: Configure replication on the replica
|
||||
command: |
|
||||
/usr/bin/mariadb -e "CHANGE MASTER TO master_host='{{ mariadb_replication_master_ip }}',
|
||||
master_user='{{ item.name }}', master_password='{{ item.password }}', master_use_gtid=slave_pos"
|
||||
with_items: "{{ mariadb_replication_user }}"
|
||||
when:
|
||||
- not slave.Is_Slave
|
||||
- not replica.Is_Slave
|
||||
no_log: true
|
||||
|
||||
# # Following (not tested) should work on ansible 2.10
|
||||
# - name: Configure replication on the slave
|
||||
# - name: Configure replication on the replica
|
||||
# mysql_replication:
|
||||
# mode: changemaster
|
||||
# master_host: "{{ mariadb_replication_master_ip }}"
|
||||
|
|
@ -29,26 +29,26 @@
|
|||
# login_unix_socket: "{{ mariadb_unix_socket }}"
|
||||
# with_items: "{{ mariadb_replication_user }}"
|
||||
# when:
|
||||
# - not slave.Is_Slave
|
||||
# - not replica.Is_Slave
|
||||
# no_log: true
|
||||
|
||||
- name: Reset slave replication
|
||||
- name: Reset replica replication
|
||||
mysql_replication:
|
||||
mode: resetslave
|
||||
login_unix_socket: "{{ mariadb_unix_socket }}"
|
||||
when:
|
||||
- not slave.Is_Slave
|
||||
- not replica.Is_Slave
|
||||
|
||||
- name: Check slave replication status (second time)
|
||||
- name: Check replica replication status (second time)
|
||||
mysql_replication:
|
||||
mode: getslave
|
||||
login_unix_socket: "{{ mariadb_unix_socket }}"
|
||||
register: slave2
|
||||
register: replica2
|
||||
no_log: true
|
||||
|
||||
- name: Start slave replication
|
||||
- name: Start replica replication
|
||||
mysql_replication:
|
||||
mode: startslave
|
||||
login_unix_socket: "{{ mariadb_unix_socket }}"
|
||||
when:
|
||||
- slave2.Slave_IO_Running == "No"
|
||||
- replica2.Slave_IO_Running == "No"
|
||||
|
|
@ -25,7 +25,7 @@ log_bin
|
|||
expire_logs_days = {{ mariadb_expire_logs_days }}
|
||||
max_binlog_size = {{ mariadb_max_binlog_size }}
|
||||
binlog_format = {{mariadb_binlog_format}}
|
||||
# the following permits to simplify the process of moving a slave to a master
|
||||
# the following permits to simplify the process of moving a replica to a master
|
||||
# role by ensuring that replication is not started on master
|
||||
skip-slave-start
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ binlog_ignore_db = {{ db.name }}
|
|||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% if mariadb_replication_role == 'slave' %}
|
||||
{% if mariadb_replication_role == 'replica' %}
|
||||
read_only
|
||||
relay-log = relay-bin
|
||||
relay-log-index = relay-bin.index
|
||||
|
|
|
|||
Loading…
Reference in New Issue