Uncategorized

mysqlfailover: A MySQL tool that inspects the master for failure and executes failover

 

A sample mysqlfailover command. The result displays the replication health status of each port.

mysqlfailover is a utility that allows users to replicate health monitoring.  It can also automatically switch to a slave database when your master has failed.  It is architected to work interactively or run while continuously updating the health information at regular intervals.  mysqlfailover monitors the master database and should it fail, it then fails over to the next available slave.  It can choose from a list of slaves that it can consider as candidate slaves.

The mysqlfailover utility works when you have the GTID-replication in MySQL 5.6 enabled.

How to use mysqlfailover

You can specify the interval you want using the –interval option.  mysqlfailover will check to see if the master server is operational using a ping operation and then checking the connector to see if the server is still working.  You can control the ping operation using the –ping option.

If the master is offline, the mysqlfailover utility will then execute the actions you have specified on the  –failover-mode option.  These actions are:

  • auto, which executes automatic failover using a list of candidate slaves, and then evaluates all the other slaves available.  If no slaves are found to be suitable, the mysqlfailover utility will exit after registering an error.
  • elect, which works the same way as auto.  The only difference is that in elect mode, the utility only considers the list of candidate slaves and ignores all the other slaves that are in the system.  If none of the candidate slaves are suitable, the mysqlfailover utility signifies an error and then exits.
  • fail, which causes the mysqlfailover utility to generate an error before exiting.  It will not promote a slave as master when the master fails.  You can use this mode when you want the mysqlfailover utility to do regular health monitoring without doing any failover.

Discovering slaves connected to the master

You can also use the mysqlfailover utility to discover all slaves that are connected to the master.  You must use the –report-host and –report-port variables on all slaves to get the right hostname and ip port of the slave.  If you do not have the correct ip port or hostname, you would not be able to monitor the health of the slaves or they may remain unlisted.

Run an external script before and after a failover.  If you have external scripts that you want to run in the event that your master server fails, then you can specify these scripts using the –exec-after and –exec-before options.

Other important options you should know include:

  • You can use the –log option to log everything that happens during commands.
  • You can get help using the –help option.
  • You can view license information using the –license option.
  • You can run a daemon, using the –daemon=<command> option.  Valid commands are start, stop, nodetach and restart.
  • You can use –force to override any registration check on master.

Need help with the mysqlfailover utility?  Contact Four Cornerstone using our contact form and work with a team of MySQL and Oracle experts who can help you get off the ground with your IT investments.

Screenshot courtesy of MySQL.

Cloud Blog

4 Ways To Benefit from…

One of the benefits you get when you work with cloud applications is that you often have quarterly updates that are packed with features. This...

Keep Reading

Artificial Intelligence

Data and Analytics: Cross the…

  Artificial intelligence is a manna sent from digital heaven. That’s how blessed your business can get if you immerse into the AI of things....

Keep Reading

Business Intelligence Blog

How Brand Names Survive in…

  The age of digital marketplace has made it possible for unknown and smaller companies to compete with better-known and well-established brands. Take for example...

Keep Reading

Artificial Intelligence

The Phenomenon That Is Artificial…

  Artificial intelligence is when a machine does cognitive functions that are more associated with humans, such as thinking, learning, problem solving, and reasoning. As...

Keep Reading

Cloud

Digital Transformation in Banking: Shift…

  The start of a new decade is already shaping up to be exciting for financial services, especially for banks as they continue to compete...

Keep Reading

Business Intelligence Blog

Data Science and Its Economic…

It would seem that artificial intelligence is the focus of businesses that are looking to future proof their organizations and stay competitive. And why not?...

Keep Reading

Data Blog

Ensure Efficient Data Science and…

In an ever-expanding landscape called Internet of Things and the exploding development of artificial intelligence, we are bombarded with complex methods of integrating data science...

Keep Reading

Business Intelligence Blog

Cybersecurity: The Top 5 Expectations…

  If you think about it, cybersecurity is closely tied to human rights, privacy, freedom, and even basic safety. As a whole, we have become...

Keep Reading

Business Intelligence Blog

Tech Security Should Be Easy…

  IT professionals know that tech security is important in everything that they do. And that there are a lot of products, tools, innovations, and...

Keep Reading

Business Intelligence Blog

The Top 6 Success Stories…

Nearly nine out of 10 digital transformation initiatives fail. Digital transformation projects fail for a variety of reasons. It can be because of a lack...

Keep Reading

Live Chat | Emergency