mha0.58gtid模式下丢数据问题修复-创新互联
问题描述:
在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"); }
文章题目:mha0.58gtid模式下丢数据问题修复-创新互联
文章URL:http://scyanting.com/article/diepcs.html