MySQL for the Internet of Things

(Steven Felgate) #1

Chapter 8


Demonstration of


High Availability Techniques


Understanding what high availability is and some of the key goals for achieving higher levels of reliability
will help you design your IOT solutions for greater reliability. As you learned in the previous chapter, it takes
a bit of work to achieve these goals, but the payoff for a modest amount of work is well worth it should your
solution expand beyond a set of discrete nodes.
However, knowing the concepts is only part of the solution. You also need to see examples of how
some of these techniques are manifested. For example, how do you detect and recover from a data collector
node failure, and how do you set up MySQL replication to switch to a new master should the master fail?
Furthermore, how does the application know this has happened?
We will explore these topics and more using example projects that illustrate the techniques in code.
Some of the examples are written in Python since these are more likely to be implemented on low-cost
computer boards or even personal or server computers. Other examples are written for the Arduino but
could also be adapted to other microcontroller boards.


■Tip The examples in this chapter present techniques rather than complete solutions. They are more of a


recipe for success than a how-to demonstration. Even so, the examples in this section are advanced techniques


that you can employ in your own solutions.


Before we jump into the code examples, let’s explore the primary tool for making your database server
more reliable: MySQL replication.


MySQL Replication Techniques


Recall MySQL replication is a mechanism that permits you to designate one server as the master and one or
more servers as slaves whereby the slaves receive copies of all changes made to the master. This permits you
to replicate the data from one server to many others. In the previous chapter, you saw how to set up MySQL
replication for hot standby or backup and manual recovery should the master fail.
While MySQL replication is easy to set up^1 and managing a small replication topology is normally not a
burden, requiring very little intervention, managing large replication topologies and solving problems that
can occur—both intentional and unintentional—can be more of a challenge.


(^1) Made easier with MySQL Utilities, as you will see.

Free download pdf