MySQL MHA introduction and advantages

Source: Internet
Author: User
Tags failover dedicated server

MySQL MHA introduction and advantages

MHA is the best choice for many enterprises that use MySQL databases for high availability. It is easy to use and powerful, and implements automatic master-slave failover Based on the MySQL replication architecture, this article mainly uses the original text to describe the main features and advantages of MHA, as much as possible through the original text to understand thoroughly, for your reference.

I. MAIN FEATURES OF MHA

MHA performs automating master failover and slave promotion with minimal downtime, usually within 10-30 seconds. MHA prevents replication consistency problems and saves on expenses of having to acquire additional servers. all this with zero performance degradation, no complexity (easy-to-install) and requiring no change to existing deployments.

MHA also provides scheduled online master switching, safely changing the currently running master to a new master, within mere seconds (0.5-2 seconds) of downtime (blocking writes only ).

MHA provides the following functionality, and can be useful in your deployments in which high availability, data integrity and near non-stop master maintenance are required.

Automatic master monitoring and failover (automatic Master monitoring and failover)

MHA can monitor MySQL masters in an existing replication environment, during Ming automatic IC master failover upon detection of master failure. MHA guarantees the consistency of all the slaves by identifying differential relay log events from the most current slave and applying them to all the other slaves, including those slaves which still haven't stored the latest relay log events. MHA can normally perform failover in a matter of seconds: 9-12 seconds to detect master failure, optionally 7-10 seconds to power off the master machine to avoid split brain, and a few seconds to apply differential relay logs to the new master. total downtime is normally 10-30 seconds. A specific slave can be designated as a candidate master (setting priorities) in a configuration file. since MHA maintains consistency between slaves, any slave can be promoted to become the new master. consistency problems, which wocould ordinarily cause sudden replication failure, will not occur.

Interactive (manually initiated) Master Failover (Interactive mode, manual triggering of Master Failover)

MHA can be configured for manually initiated (non-automatic), interactive failover, without monitoring the master.

Non-interactive master failover (Master failover in Non-interactive mode)

Non-interactive, automatic master failover without monitoring the master is also supported. this feature is especially useful when MySQL master software monitoring is already in use. for example, you can use Pacemaker (Heartbeat) for detecting master failure and virtual IP address takeover, while using MHA for master failover and slave promotion.

Online switching master to a different host (switch the Master to a different host Online)

It is often necessary to migrate an existing master to a different machine, like when the current master has H/w raid controller or RAM problems, or when you want to replace it with a faster machine, etc. this is not a master crash, but scheduled master maintenance is required. scheduled master maintenance shoshould be done as quickly as possible, since it entails partial downtime (master writes are disabled ). on the other hand, you shoshould block/kill current running sessions very carefully because consistency problems between different masters may occur (I. e "updating master1, updating master 2, committing master1, getting error on committing master 2" will result in data inconsistency ). both fast master switch and graceful blocking writes are required.

MHA provides graceful master switching within 0.5-2 seconds of writer blockage. 0.5-2 seconds of writer downtime is often acceptable, so you can switch masters even without allocating a scheduled maintenance window. actions such as upgrading to higher versions, faster machine, etc. become much easier.

Ii. Advantages of MHA

Master failover and slave promotion can be done very quickly

MHA normally can do failover in seconds (9-12 seconds to detect master failure, optionally 7-10 seconds to power off the master machine to avoid split brain, a few seconds for applying differential relay logs to the new master, so total downtime is normally 10-30 seconds), as long as slaves does not delay replication seriously. after recovering the new master, MHA recovers the rest slaves in parallel. even though you have tens of slaves, it does not affect master recovery time, and you can recover slaves very quickly.

DeNA uses MHA on 150 + {master, slaves} environments. when one of the master crashed, MHA completed failover in 4 seconds. doing failover in 4 seconds is never possible with traditional active/passive clustering solution.

Master crash does not result in data inconsistency

When the current master crashes, MHA automatically identifies differential relay log events between slaves, and applies to each slave. so finally all slaves can be in sync, as long as all slave servers are alive. by using together with Semi-Synchronous Replication, (almost) no data loss can also be guaranteed.

No need to modify current MySQL settings (MHA works with regular MySQL (5.0 or later ))

One of the most important design principles of MHA is to make MHA easy to use as long as possible. MHA works with existing traditional MySQL 5.0 + master-slaves replication environments. though extends other HA solutions require to change MySQL deployment settings, MHA does not force such tasks for DBAs. MHA works with the most common two-tier single master and multiple slaves environments. MHA works with both asynchronous and semi-synchronous MySQL replication. starting/Stopping/Upgrading/Downgrading/Installing/Uninstalling MHA can be done without changing (including starting/stopping) MySQL replication. when you need to upgrade MHA to newer versions, you don't need to stop MySQL. just replace with newer MHA versions and restart MHA Manager is fine.

MHA works with normal MySQL versions starting from MySQL 5.0. some HA solutions require special MySQL versions (I. e. mySQL Cluster, MySQL with Global Transaction ID, etc), but you may not like to migrate applications just for master HA. in our cases people have already deployed into legacy MySQL applications and they don't want to spend too much time to migrate to different storage engines or newer bleeding edge distributions just for master HA. MHA works with normal MySQL versions including 5.0/5.1/5.5 so you don't need to migrate.

No need to increase lots of servers

MHA consists of MHA Manager and MHA Node. MHA Node runs on the MySQL server when failover/recovery happens so it doesn't require additional server. MHA Manager normally runs on a dedicated server so you need to add one (or two for HA) server (s), but MHA Manager can monitor lots of (even 100 +) masters from single server, so the total number of servers is not increased so much. note that it is even possible to run MHA Manager on one of slave servers. in this case total number of servers is not increased at all.

No performance penalty

MHA works with regular asynchronous or semi-synchronous MySQL replication. when monitoring master server, MHA just sends ping packets to master every N seconds (default 3) and it does not send heavy queries. you can perform CT as fast performance as regular MySQL replication.

Works with any storage engine

MHA works with any storage engines as long as MySQL replication works, not limited to InnoDB (crash-safe, transactional storage engine ). even though you use legacy MyISAM environments that are not easy to migrate, you can use MHA.

This article permanently updates the link address:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.