pengmingde / mysql-master-ha

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

master_ip_online_change DBI connect #41

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
1.have 1 master 1 slave.
2 When i'm running the command  masterha_master_switch --master_state=alive 
--conf=/etc/app1.cnf --new_master_host=db1  i get the following output. It 
seems that the manager connect to the mysql DB using root no pass 

Mon Nov 26 00:46:38 2012 - [info] MHA::MasterRotate version 0.53.
Mon Nov 26 00:46:38 2012 - [info] Starting online master switch..
Mon Nov 26 00:46:38 2012 - [info] 
Mon Nov 26 00:46:38 2012 - [info] * Phase 1: Configuration Check Phase..
Mon Nov 26 00:46:38 2012 - [info] 
Mon Nov 26 00:46:38 2012 - [info] Reading default configuratoins from 
/etc/masterha_default.cnf..
Mon Nov 26 00:46:38 2012 - [info] Reading application default configurations 
from /etc/app1.cnf..
Mon Nov 26 00:46:38 2012 - [info] Reading server configurations from 
/etc/app1.cnf..
Mon Nov 26 00:46:38 2012 - [info] Current Alive Master: db1(10.0.1.248:3306)
Mon Nov 26 00:46:38 2012 - [info] Alive Slaves:
Mon Nov 26 00:46:38 2012 - [info]   db3(10.0.1.49:3306)  
Version=5.5.28-0ubuntu0.12.04.2-log (oldest major version between slaves) 
log-bin:enabled
Mon Nov 26 00:46:38 2012 - [info]     Replicating from 
10.0.1.248(10.0.1.248:3306)

It is better to execute FLUSH NO_WRITE_TO_BINLOG TABLES on the master before 
switching. Is it ok to execute on db1(10.0.1.248:3306)? (YES/no): 
Mon Nov 26 00:46:40 2012 - [info] Executing FLUSH NO_WRITE_TO_BINLOG TABLES. 
This may take long time..
Mon Nov 26 00:46:40 2012 - [info]  ok.
Mon Nov 26 00:46:40 2012 - [info] Checking MHA is not monitoring or doing 
failover..
Mon Nov 26 00:46:40 2012 - [info] Checking replication health on db3..
Mon Nov 26 00:46:40 2012 - [info]  ok.
Mon Nov 26 00:46:40 2012 - [info] db3 can be new master.
Mon Nov 26 00:46:40 2012 - [info] 
From:
db1 (current master)
 +--db3

To:
db3 (new master)

Starting master switch from db1(10.0.1.248:3306) to db3(10.0.1.49:3306)? 
(yes/NO): no
Continue? (yes/NO): yes
Enter new master host name: db3
Master switch to db3(10.0.1.49:3306). OK? (yes/NO): yes
Mon Nov 26 00:47:03 2012 - [info] Checking whether db3(10.0.1.49:3306) is ok 
for the new master..
Mon Nov 26 00:47:03 2012 - [info]  ok.
Mon Nov 26 00:47:03 2012 - [info] ** Phase 1: Configuration Check Phase 
completed.
Mon Nov 26 00:47:03 2012 - [info] 
Mon Nov 26 00:47:03 2012 - [info] * Phase 2: Rejecting updates Phase..
Mon Nov 26 00:47:03 2012 - [info] 
Mon Nov 26 00:47:03 2012 - [info] Executing master ip online change script to 
disable write on the current master:
Mon Nov 26 00:47:03 2012 - [info]   /opt/scripts/master_ip_online_change 
--command=stop --orig_master_host=db1 --orig_master_ip=10.0.1.248 
--orig_master_port=3306 --new_master_host=db3 --new_master_ip=10.0.1.49 
--new_master_port=3306  
Got Error: DBI 
connect(';host=10.0.1.49;port=3306;mysql_connect_timeout=4','',...) failed: 
Access denied for user 'root'@'10.0.1.45' (using password: NO) at 
/usr/share/perl5/MHA/DBHelper.pm line 181
 at /opt/scripts/master_ip_online_change line 128

What is the expected output? What do you see instead?
Connect To the db with username and password in the configuration file. 
What version of the product are you using? On what operating system?
0.5.3

Please provide any additional information below.
Below my conf files 

# mysql user and password
  user=replication
  repl_user=replication 
  repl_password=xxx
  password=xxx
  ssh_user=root
  # working directory on the manager
  manager_workdir=/var/log/masterha/app1
  # working directory on MySQL servers
  remote_workdir=/var/log/masterha/app1
  manager_log=/var/log/masterha/app1.log 
  [server1]
  hostname=db1
  ignore_fail=1 

  [server3]
  hostname=db3
  ignore_fail=1

--------------------
[server default]
  user=replication
  password=xxx
 repl_password=xxx
  ssh_user=root
  master_binlog_dir= /var/log/mysql
  remote_workdir=/data/log/masterha
   ping_interval=3
  master_ip_failover_script= /opt/scripts/master_ip_failover
  master_ip_online_change_script= /opt/scripts/master_ip_online_change
~                                                                               

~                                                                            

Regards 

Original issue reported on code.google.com by andrea.c...@gmail.com on 26 Nov 2012 at 1:06

GoogleCodeExporter commented 9 years ago
master_ip_online_change (and master_ip_failover) scripts don't read MHA 
configuration files. They get ip/host/port information as command line 
arguments 
(http://code.google.com/p/mysql-master-ha/wiki/Parameters#master_ip_failover_scr
ipt) but do not get MySQL account information. So if you want to connect to 
MySQL servers (orig/new masters) and run specific SQL statements, you need such 
as: 1. hard-coding MySQL username/password in the master_ip_online_change 
script,  2. reading MHA conf file and getting user and password parameter 
value. It is easy by using Config::Tiny Perl module but it is generally 
language-independent.

Original comment by Yoshinor...@gmail.com on 27 Nov 2012 at 8:35

GoogleCodeExporter commented 9 years ago
Thank you .  it works . Very good impressions from my first tests. 

Original comment by andrea.c...@gmail.com on 29 Nov 2012 at 1:46

GoogleCodeExporter commented 9 years ago
Thanks for the kind words. Upcoming version 0.54 passes user information 
(--new_master_user and --new_master_port for master_ip_failover_script, and 
supporting --orig_master_user, --orig_master_password, --new_master_user and 
--new_master_password for master_ip_online_change_script) so you'll be able to 
get as arguments.

Original comment by Yoshinor...@gmail.com on 1 Dec 2012 at 1:24