免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 5382 | 回复: 6
打印 上一主题 下一主题

mysql-mha搭建问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2014-03-05 20:57 |只看该作者 |倒序浏览
各位大神帮忙看下:
我测试**安装的mysql-mha
os:Red Hat Enterprise Linux Server release 5.5   
mysql version: 5.5.21
3台机器
m1 主
slave  (从)
salve2 (从)
3台机器的主从已经搭建完成,已经在3台机器上安装完 mha-node ,并在m1机器上安装了mha-manage

[root@m1 mha4mysql-manager-0.55]# cat /etc/app1.cnf
[server default]
manager_workdir=/masterha/app1  
manager_log=/masterha/app1/manager.log  
user=root
password=123
ssh_user=root
repl_user=rep
repl_password=rep
ping_interval=1
shutdown_script=""
report_script=""
master_ip_failover_script=/usr/local/bin/master_ip_failover
master_ip_online_change_script=/usr/local/bin/master_ip_online_change_script
[server1]
hostname=192.168.92.100
candidate_master=1

[server2]
hostname=192.168.92.102
candidate_master=1

[server3]
hostname=192.168.92.103
candidate_master=1

在m1上 (已经做了mysql上面root授权和系统ssh互信任并且手动测试没问题)出现如下错误
masterha_check_ssh --conf=/etc/app1.cnf
Wed Mar  5 20:16:26 2014 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Wed Mar  5 20:16:26 2014 - [info] Reading application default configurations from /etc/app1.cnf..
Undefined subroutine &MHA::NodeUtil::escape_for_shell called at /usr/lib/perl5/site_perl/5.8.8/MHA/Config.pm line 291.

补充下:/usr/lib/perl5/site_perl/5.8.8/MHA/Config.pm line 291附近的内容为:
287   # set escaped_user and escaped_password
    288   foreach my $key ( 'user', 'password' ) {
    289     my $new_key = "escaped_" . $key;
    290     if ( $server->{$key} ) {
    291       $server->{$new_key} = MHA::NodeUtil::escape_for_shell( $server->{$        key} );
    292     }
    293     else {
    294       $server->{$new_key} = "";
    295     }
    296   }
    297   return $server;
    298 }
请各位大神给分析下那里有问题?跪谢

论坛徽章:
0
2 [报告]
发表于 2014-03-06 11:47 |只看该作者
注释server3 的candidate_master试试

论坛徽章:
0
3 [报告]
发表于 2014-03-07 09:59 |只看该作者
看/masterha/app1/manager.log 报错

论坛徽章:
3
丑牛
日期:2014-02-25 15:19:10金牛座
日期:2014-02-28 19:01:322015亚冠之西悉尼流浪者
日期:2015-06-10 15:01:09
4 [报告]
发表于 2014-03-07 18:32 |只看该作者
mha magager最好不要装在mysql节点上,要独立出来。

论坛徽章:
0
5 [报告]
发表于 2014-03-11 17:02 |只看该作者
楼主,你好。我也遇到类似的问题。
[error][/usr/lib/perl5/vendor_perl/MHA/MasterMonitor.pm, ln315] Error happend on checking configurations. Can't exec "/usr/local/bin/master_ip_failover": Permission denied at /usr/lib/perl5/vendor_perl/MHA/ManagerUtil.pm line 68.
提示的68行内容: return MHA::NodeUtil::system_rc( system($cmd) );
这个是加了脚本master_ip_failover导致的,不用这个脚本就没有错误。请问你解决了吗?

论坛徽章:
0
6 [报告]
发表于 2014-03-11 17:04 |只看该作者
为什么在managerUtil.pm中执行return MHA::NodeUtil::system_rc( system($cmd) );没有权限呢???是脚本的问题还是其他原因呢
我的master_ip_failover脚本代码如下,是从网上找的,只改了vip
  1. #!/usr/bin/env perl
  2. use strict;
  3. use warnings FATAL => 'all';

  4. use Getopt::Long;

  5. my (
  6.     $command,          $ssh_user,        $orig_master_host, $orig_master_ip,
  7.     $orig_master_port, $new_master_host, $new_master_ip,    $new_master_port
  8. );

  9. # my $vip = '172.16.21.119/24';  # Virtual IP
  10. my $vip = '192.168.1.250/24';  # Virtual IP
  11. my $key = "1";
  12. my $ssh_start_vip = "/sbin/ifconfig eth0:$key $vip";
  13. my $ssh_stop_vip = "/sbin/ifconfig eth0:$key down";

  14. GetOptions(
  15.     'command=s'          => \$command,
  16.     'ssh_user=s'         => \$ssh_user,
  17.     'orig_master_host=s' => \$orig_master_host,
  18.     'orig_master_ip=s'   => \$orig_master_ip,
  19.     'orig_master_port=i' => \$orig_master_port,
  20.     'new_master_host=s'  => \$new_master_host,
  21.     'new_master_ip=s'    => \$new_master_ip,
  22.     'new_master_port=i'  => \$new_master_port,
  23. );

  24. exit &main();

  25. sub main {

  26.     print "\n\nIN SCRIPT TEST====$ssh_stop_vip==$ssh_start_vip===\n\n";

  27.     if ( $command eq "stop" || $command eq "stopssh" ) {

  28.         # $orig_master_host, $orig_master_ip, $orig_master_port are passed.
  29.         # If you manage master ip address at global catalog database,
  30.         # invalidate orig_master_ip here.
  31.         my $exit_code = 1;
  32.         eval {
  33.             print "Disabling the VIP on old master: $orig_master_host \n";
  34.             &stop_vip();
  35.             $exit_code = 0;
  36.         };
  37.         if ($@) {
  38.             warn "Got Error: $@\n";
  39.             exit $exit_code;
  40.         }
  41.         exit $exit_code;
  42.     }
  43.     elsif ( $command eq "start" ) {

  44.         # all arguments are passed.
  45.         # If you manage master ip address at global catalog database,
  46.         # activate new_master_ip here.
  47.         # You can also grant write access (create user, set read_only=0, etc) here.
  48.         my $exit_code = 10;
  49.         eval {
  50.             print "Enabling the VIP - $vip on the new master - $new_master_host \n";
  51.             &start_vip();
  52.             $exit_code = 0;
  53.         };
  54.         if ($@) {
  55.             warn $@;
  56.             exit $exit_code;
  57.         }
  58.         exit $exit_code;
  59.     }
  60.     elsif ( $command eq "status" ) {
  61.         print "Checking the Status of the script.. OK \n";
  62.         `ssh $ssh_user\@cluster1 \" $ssh_start_vip \"`;
  63.         exit 0;
  64.     }
  65.     else {
  66.         &usage();
  67.         exit 1;
  68.     }
  69. }

  70. # A simple system call that enable the VIP on the new master
  71. sub start_vip() {
  72.     `ssh $ssh_user\@$new_master_host \" $ssh_start_vip \"`;
  73. }
  74. # A simple system call that disable the VIP on the old_master
  75. sub stop_vip() {
  76.     `ssh $ssh_user\@$orig_master_host \" $ssh_stop_vip \"`;
  77. }

  78. sub usage {
  79.     print
  80.     "Usage: master_ip_failover --command=start|stop|stopssh|status --orig_master_host=host --orig_master_ip=ip --orig_master_port=port --new_master_host=host --new_master_ip=ip --new_master_port=port\n";
  81. }
复制代码

论坛徽章:
0
7 [报告]
发表于 2014-03-12 21:33 |只看该作者
mark一下,有同样的问题。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP