OrclChina / mysql-master-ha

Automatically exported from code.google.com/p/mysql-master-ha
0 stars 0 forks source link

masterha_master_switch does not configure slave replication #1

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1. I have testdb01 and testdb02 as master and slaves. I am switching to new 
master testdb02
2. masterha_master_switch --conf=cluster.conf --master_state=alive 
--new_master_host=testdb02
2.
3.

What is the expected output? What do you see instead?

 The script should configure testdb02 as master and testdb01 as a slave of testdb02. Instead it spews the following output.
===================================
Wed Sep  7 00:30:49 2011 - [info] MHA::MasterRotate version 0.51.
Wed Sep  7 00:30:49 2011 - [info] Starting online master switch..
Wed Sep  7 00:30:49 2011 - [info] 
Wed Sep  7 00:30:49 2011 - [info] * Phase 1: Configuration Check Phase..
Wed Sep  7 00:30:49 2011 - [info] 
Wed Sep  7 00:30:49 2011 - [warn] Global configuration file 
/etc/masterha_default.cnf not found. Skipping.
Wed Sep  7 00:30:49 2011 - [info] Reading application default configurations 
from cluster.conf..
Wed Sep  7 00:30:49 2011 - [info] Reading server configurations from 
cluster.conf..
Wed Sep  7 00:30:49 2011 - [info] Current Master: testdb01(192.168.12.10:3306)
Wed Sep  7 00:30:49 2011 - [info] Alive Slaves:
Wed Sep  7 00:30:49 2011 - [info]   testdb02(192.168.12.11:3306)  
Version=5.1.52-community-log (oldest major version between slaves) 
log-bin:enabled
Wed Sep  7 00:30:49 2011 - [info]     Replicating from 
testdb01(192.168.12.10:3306)

It is better to execute FLUSH NO_WRITE_TO_BINLOG TABLES on the master before 
switching. Is it ok to execute on testdb01(192.168.12.10:3306)? (YES/no): yes
Wed Sep  7 00:31:01 2011 - [info] Executing FLUSH NO_WRITE_TO_BINLOG TABLES. 
This may take long time..
Wed Sep  7 00:31:01 2011 - [info]  ok.
Wed Sep  7 00:31:01 2011 - [info] Checking MHA is not monitoring or doing 
failover..
Wed Sep  7 00:31:01 2011 - [info] Checking replication health on testdb02..
Wed Sep  7 00:31:01 2011 - [info]  ok.
Wed Sep  7 00:31:01 2011 - [info] testdb02 can be new master.
Wed Sep  7 00:31:01 2011 - [info] 
From:
testdb01 (current master)
 +--testdb02

To:
testdb02 (new master)

Starting master switch from testdb01(192.168.12.10:3306) to 
testdb02(192.168.12.11:3306)? (yes/NO): yes
Wed Sep  7 00:31:19 2011 - [info] ** Phase 1: Configuration Check Phase 
completed.
Wed Sep  7 00:31:19 2011 - [info] 
Wed Sep  7 00:31:19 2011 - [info] * Phase 2: Rejecting updates Phase..
Wed Sep  7 00:31:19 2011 - [info] 
master_ip_online_change_script is not defined. If you do not disable writes on 
the current master manually, applications keep writing on the current master. 
Is it ok to proceed? (yes/NO): yes
Wed Sep  7 00:31:40 2011 - [info] Locking all tables on the orig master to 
reject updates from everybody (including root):
Wed Sep  7 00:31:40 2011 - [info] Executing FLUSH TABLES WITH READ LOCK..
Wed Sep  7 00:31:40 2011 - [info]  ok.
Wed Sep  7 00:31:40 2011 - [info] Orig master binlog:pos is 
mysql-bin.000005:519.
Wed Sep  7 00:31:40 2011 - [info]  Waiting to execute all relay logs on 
testdb02(192.168.12.11:3306)..
Wed Sep  7 00:31:40 2011 - [info]  master_pos_wait(mysql-bin.000005:519) 
completed on testdb02(192.168.12.11:3306). Executed 0 events.
Wed Sep  7 00:31:40 2011 - [info]   done.
Wed Sep  7 00:31:40 2011 - [info] Getting new master's binlog name and 
position..
Wed Sep  7 00:31:40 2011 - [info]  mysql-bin.000004:106
Wed Sep  7 00:31:40 2011 - [info]  All other slaves should start replication 
from here. Statement should be: CHANGE MASTER TO MASTER_HOST='testdb02 or 
192.168.12.11', MASTER_PORT=3306, MASTER_LOG_FILE='mysql-bin.000004', 
MASTER_LOG_POS=106, MASTER_USER='slave', MASTER_PASSWORD='xxx';
Wed Sep  7 00:31:40 2011 - [info] 
Wed Sep  7 00:31:40 2011 - [info] * Switching slaves in parallel..
Wed Sep  7 00:31:40 2011 - [info] 
Wed Sep  7 00:31:40 2011 - [info] Unlocking all tables on the orig master:
Wed Sep  7 00:31:40 2011 - [info] Executing UNLOCK TABLES..
Wed Sep  7 00:31:40 2011 - [info]  ok.
Wed Sep  7 00:31:40 2011 - [info] All new slave servers switched successfully.
Wed Sep  7 00:31:40 2011 - [info] 
Wed Sep  7 00:31:40 2011 - [info] * Phase 5: New master cleanup phease..
Wed Sep  7 00:31:40 2011 - [info] 
Wed Sep  7 00:31:40 2011 - [info] Switching master to 
testdb02(192.168.12.11:3306) completed successfully.
===============================

 I want the script to configure new slave so that it connects and gets updates from new master.

What version of the product are you using? On what operating system?

centos 5.6.

Please provide any additional information below.

 I have only two hosts defined in cluster.conf.
testdb01 and testdb02

Original issue reported on code.google.com by dimecybo...@gmail.com on 7 Sep 2011 at 6:04

GoogleCodeExporter commented 8 years ago
MHA doesn't provide a script to setup a new slave because there are many 
existing solutions. For example: 
http://www.mysqlperformanceblog.com/2009/05/07/btw-xtrabackup-is-not-only-backup
/

Original comment by Yoshinor...@gmail.com on 8 Nov 2011 at 9:47

GoogleCodeExporter commented 8 years ago
I don't understand the answer … It's not about adding a new slave but 
switching roles. If we promote the slave as a new master, we want the old 
master to become a slave !

Original comment by cscet...@gmail.com on 30 Oct 2012 at 2:35

GoogleCodeExporter commented 8 years ago
Maybe I misunderstood your question. For online master switch, there is a 
"--orig_master_is_new_slave" parameter.

http://code.google.com/p/mysql-master-ha/wiki/masterha_master_switch#Scheduled%2
8Online%29_Master_Switch

Original comment by Yoshinor...@gmail.com on 30 Oct 2012 at 10:51

GoogleCodeExporter commented 8 years ago
I found this option and I think it's the answer the submitter was waiting for.

Original comment by cscet...@gmail.com on 31 Oct 2012 at 3:16