本文在介绍关于mha在gtid模式下故障解决方法的基础上,重点探讨了其具体步骤,步骤简单易上手操作,文章内容步步紧凑,希望大家根据这篇文章可以有所收获。
问题描述:
在gtid模式下 ,mha发生故障切换 ,如果Linux主机还存活 ,不会去比对master的日志,获取差异日志 ,有导致数据丢失的风险 。
问题修复:
找到 MasterFailover.pm 文件 ,将下文! 去掉
if ( !$_server_manager->is_gtid_auto_pos_enabled() ) { $log->info(); $log->info("* Phase 3.2: Saving Dead Master's Binlog Phase..\n"); $log->info(); save_master_binlog($dead_master); }
去掉后的代码
if ( $_server_manager->is_gtid_auto_pos_enabled() ) { $log->info(); $log->info("* Phase 3.2: Saving Dead Master's Binlog Phase..\n"); $log->info(); save_master_binlog($dead_master); }
找到 apply_binlog_to_master 函数定义的位置
sub apply_binlog_to_master($) { my $target = shift; my $err_file = "$g_workdir/mysql_from_binlog.err"; my $command = "cat $_diff_binary_log | mysql --binary-mode --user=$target->{mysql_escaped_user} --password=$target->{mysql_escaped_password} --host=$target->{ip} --port=$target->{port} -vvv --unbuffered > $err_file 2>&1"; $log->info("Checking if super_read_only is defined and turned on.."); my ($super_read_only_enabled, $dbh) = MHA::SlaveUtil::check_if_super_read_only($target->{hostname}, $target->{ip}, $target->{port}, $target->{user}, $target->{password}); if ($super_read_only_enabled) { MHA::SlaveUtil::disable_super_read_only($dbh); } else { $log->info(" not present or turned off, ignoring.\n"); }
修改后的代码 cat $_diff_binary_log
sub apply_binlog_to_master($) { my $target = shift; my $err_file = "$g_workdir/mysql_from_binlog.err"; my $command = "mysqlbinlog $_diff_binary_log --skip-gtids=true | mysql --binary-mode --user=$target->{mysql_escaped_user} --password=$target->{mysql_escaped_password} --host=$target->{ip} --port=$target->{port} -vvv --unbuffered > $err_file 2>&1"; $log->info("Checking if super_read_only is defined and turned on.."); my ($super_read_only_enabled, $dbh) = MHA::SlaveUtil::check_if_super_read_only($target->{hostname}, $target->{ip}, $target->{port}, $target->{user}, $target->{password}); if ($super_read_only_enabled) { MHA::SlaveUtil::disable_super_read_only($dbh); } else { $log->info(" not present or turned off, ignoring.\n"); }
以上就是mha在gtid模式下故障的解决方法,详细使用情况还需要大家自己亲自动手使用过才能领会。如果想了解更多相关内容,欢迎关注亿速云行业资讯频道!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。