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模式下丢数据问题修复
文章转载:http://cdiso.cn/article/jpjshg.html