Get the App
SLTechnology News&Howtos  ›  Servers  › 

The solution to the failure of mha in gtid mode

Shulou Source: shulou.com Published: 2022-06-03 03:40:25 09月25日 Update

On the basis of introducing the fault solution of mha in gtid mode, this paper focuses on its concrete steps, which are simple and easy to operate, and the content of the article is compact step by step. I hope you can get something according to this article.

Problem description:

In gtid mode, mha fails over. If the Linux host is still alive, it will not compare master logs and obtain differential logs, which may lead to data loss.

Problem fix:

Find the MasterFailover.pm file, which will follow! Remove

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);}

The removed code

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);}

Find the location defined by the apply_binlog_to_master function

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");}

Modified code 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");}

The above is the solution to the failure of mha in gtid mode, and you need to use it yourself in order to understand the details. If you want to know more about it, welcome to follow the industry information channel!

Tags: Faults patterns methods code content logs steps problems compact following host do-it-yourself location function basis that is differences situations data files Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Shulou Information MariaDB Docker Shulou Technology