lyle at netcourrier
Jul 24, 2012, 8:20 AM
MySQL Master/Slave replication issue
- centos 5.8 x86_64
- heartbeat 3.0.3
- pacemaker 1.0.12
- latest mysql agent (from github) (there is an error in log message in block 'pre-demote'. 'post-demote' is used and it's confusing in logs. I have done the change in the script)
I have mysql in master/slave replication on 2 nodes (centreon-failover-dbmaster and centreon-failover-dbslave). In normal state, role 'master' is on 'centreon-failover-dbmaster' and 'slave' role is on 'centreon-failover-dbslave'. The procedure:
- I halt the server 'centreon-failover-dbmaster' ('halt' command): it's ok. The role 'master' is switched on 'centreon-failover-dbslave' and there is no issue in replication (i have checked)
- there is some writes on new MySQL masters
- I start the server 'centreon-failover-dbmaster': it's not ok. I have a MySQL replication issue (duplicate entry key).
Logs for 'centreon-failover-dbmaster': http://pastebin.com/kbTLYJE1
Logs for 'centreon-failover-dbslave' : http://pastebin.com/Wf9R3inW
Pacemaker global configuration: http://pastebin.com/mpbYfuKS
When i'm reading logs, i have the following:
- start server 'centreon-failover-dbmaster'
- pre-demote, demote and post-demote mysql service on 'centreon-failover-dbslave'
- start mysql service on 'centreon-failover-dbmaster': there is no master (indeed, 'centreon-failover-dbslave' is demoted) (log: 'No MySQL master present - clearing replication state')
- promote mysql service on 'centreon-failover-dbmaster': 'centreon-failover-dbmaster' didn't get writes from 'centreon-failover-dbslave' :'(. That's the problem
- post-promote mysql service on 'centreon-failover-dbslave': slave replication is activated (but the master is not consistent. And duplicate entry appears because 'centreon-failover-dbmaster' is late)
The chain or script seems not good. Moreover, i would prefer to avoid an auto failback (master/slave role). When the master switches, how can i do to tell me to stay ? (like with the stickiness) I don't want a command after to use (because if the server is up before the command: database is not synced anymore)
Thanks a lot.