GTID Mysql replication?

69 views
Skip to first unread message

Evan Tahler

unread,
Dec 16, 2014, 1:07:23 AM12/16/14
to ansible...@googlegroups.com
Hi!

Is there any (planned) support for GTID-based replication in the mysql-replication package?

It looks like someone started this here, but didn't get it back into master. 

Evan Tahler

unread,
Dec 21, 2014, 7:45:21 PM12/21/14
to ansible...@googlegroups.com
Here's how I implemented this using the command line mysql args:

- name: Check if slave is already configured for replication
  mysql_replication: mode=getslave
  register: slave
  ignore_errors: true # on the first run, this will error because not replicating yet
  when: ansible_default_ipv4.address != mysql_master_ip

- name: Get the current master server's replication status
  mysql_replication: "mode=getmaster login_user='{{ mysql_replication_user }}' login_password='{{ mysql_replication_pass }}' login_host='{{ mysql_master_ip }}'"
  register: mysql_repl_stat
  delegate_to: "{{ mysql_master_name }}"
  when: ansible_default_ipv4.address != mysql_master_ip

- name: ensure mysql replication
  when: "slave|failed and ansible_default_ipv4.address != mysql_master_ip
  command: "
      /usr/bin/mysql -u {{ mysql_user }} -p{{ mysql_pass }} -e 
      \" 
      STOP SLAVE;
      RESET MASTER;
      SET GLOBAL gtid_purged='{{ mysql_repl_stat.Executed_Gtid_Set }}'; 
      CHANGE MASTER TO MASTER_HOST='{{ mysql_master_ip }}', MASTER_USER='{{ mysql_replication_user }}', MASTER_PASSWORD='{{ mysql_replication_pass }}', MASTER_AUTO_POSITION=1; 
      START SLAVE; 
      \"

Evan Tahler

unread,
Dec 21, 2014, 7:46:12 PM12/21/14
to ansible...@googlegroups.com
It would be great to have this baked in to the mysql replication module
Reply all
Reply to author
Forward
0 new messages