Professional Documents
Culture Documents
Failover Clustering
Delivering High Availability with MySQL on Windows
Table of Contents
Summary .........................................................................................................3
Value of MySQL on Windows .......................................................................3
Approaches to High Availability with MySQL .............................................4
MySQL Replication ....................................................................................6
MySQL Cluster ..........................................................................................7
Introduction to Windows Server 2008 R2 Failover Clustering ..................7
Setting up MySQL with Windows Server 2008 R2 Failover Clustering ....8
Target Configuration ..................................................................................8
Pre-Requisites ...........................................................................................9
Steps to Configure MySQL for Windows Failover Clustering .................10
Step 1. Configure iSCSI in software (optional) .....................................10
Step 2. Ensure Windows Failover Clustering is enabled .....................12
Step 3. Install MySQL as a service on both servers ............................13
Step 4. Migrate MySQL binaries & data to shared storage ..................13
Step 5. Create Windows Failover Cluster ............................................15
Step 6. Create Cluster of MySQL Servers within Windows Cluster .....17
Step 7. (Optional) Add asynchronous replication to an external slave 19
Step 8. Test the cluster .........................................................................19
Step 9. MySQL Upgrades.....................................................................22
Conclusion....................................................................................................23
Additional Resources ..................................................................................23
Page 2
Summary
Microsoft Windows is consistently ranked as the top development platform for MySQL, and outranks any
individual Linux distribution as the leading platform for MySQL deployments, according to surveys of the
MySQL user community.
For Windows customers, the advantages of using MySQL are clear: low Total Cost of Ownership (TCO);
broad platform support and ease-of-use.
With the release of MySQL 5.5, Oracle demonstrated the benefits of focused development activity for the
Windows platform with significant enhancements in performance and scalability. MySQL delivered over 5x
higher throughput than previous MySQL releases on Windows. 1
Following the certification and support of MySQL with Windows Server Failover Clustering (WSFC),
organizations can now safely deploy business-critical applications demanding high levels of availability,
powered by the MySQL database.
This whitepaper discusses how Windows Server Failover Clustering with MySQL provides a solution to
reduce downtime and guard against data loss, and then steps a user through the processes necessary to
configure, provision and run MySQL on a Windows Server 2008 R2 cluster.
By the end of this paper, developers and administrators will be able to deploy business critical applications
with MySQL on Windows Server, with the added reassurance of knowing that the solution has been certified
and is fully supported.
http://mysql.com/why-mysql/windows/
Page 3
Figure 1 MySQL Delivers 90% Lower TCO than Microsoft SQL Server
Term: 3 Years
Users: Unlimited (web)
Servers: 4
CPUs/Server: 4
Hardware: Intel x86
MySQL: MySQL Enterprise Edition
Microsoft: SQL Server Enterprise Edition
Page 4
valuable assets and running business-critical applications. Just minutes of downtime can often result in
significant amounts of lost revenue and unsatisfied customers. Making database applications highly available
is therefore a top priority for all organizations.
MySQL provides a number of options to make a database infrastructure highly available. Selecting the high
availability solution that is right for you is largely dependent on how many nines of availability you require
and the type of application you are deploying. The solutions for MySQL high availability on the Windows
platform covers a broad spectrum of service level requirements, as illustrated in Figure 2.
By understanding the availability requirements for each application it is possible to map the database to the
appropriate high availability architecture.
Figure 3 attempts to map common application types to high availability architectures, based on best practices
observed from the MySQL user base. Of course, each organization is unique, and so while the mapping
below may not be appropriate to every use-case, it does serve as a reference point to begin investigating
those HA architectures which can potentially best serve your requirements.
Page 5
MySQL Replication
Using MySQL Replication, organizations can cost-effectively deliver a high availability solution. Master/Slave
replication enables operations to quickly fail-over to another server in the event of a hardware or software
problem. In addition, with MySQL replication, organizations can incrementally scale out their infrastructure to
accommodate exponentially growing capacity demands.
MySQL Replication ships out of the box and is used extensively by some of the worlds most highly trafficked
Web sites including Facebook, YouTube, Google, Yahoo!, flickr and Wikipedia. In MySQL 5.5, new semisynchronous replication and replication Heart Beat improve the reliability of data replication and the speed of
failover for application availability.
You can learn more about MySQL Replication in the whitepaper posted as follows:
http://www.mysql.com/why-mysql/white-papers/mysql-wp-replication.php
MySQL replication can be used in combination with Windows Server Failover Clustering to provide an
integrated solution for both high availability and scalability. The MySQL master server can be deployed in a
redundant Active / Passive pair, with replication slaves attached to the master. In the event of failure of the
master, the MySQL service is automatically restarted on the Passive server, and the replication slaves
failover with the service, without operator intervention. In the event that there is a failure in the Windows
2
Users must escalate issues related to Windows Server and its associated clustering mechanisms directly to Microsoft.
Page 6
Server Failover Cluster that cannot be automatically recovered (for example a corruption of the shared file
system), one of the slaves can be promoted to be the new master.
MySQL Cluster
MySQL Cluster is a write-scalable, shared-nothing, real-time transactional database, combining 99.999%
availability with the low TCO of open source. With a distributed, multi-master architecture and no single point
of failure, MySQL Cluster is able to scale horizontally on commodity hardware to serve read and write
intensive workloads, accessed via SQL and NoSQL interfaces.
MySQL Cluster's real-time design delivers predictable, millisecond response times with the ability to service
millions of operations per second. Support for in-memory and disk-based data, automatic data partitioning
(sharding) with load balancing and the ability to add nodes to a running cluster with zero downtime allows
linear database scalability to handle the most unpredictable web, telecoms and enterprise workloads.
You can learn more about the architecture and capabilities of MySQL Cluster from the whitepaper posted at:
http://www.mysql.com/why-mysql/white-papers/mysql_wp_cluster7_architecture.php
While the application is restarted immediately, there may be a delay until service is restored for example
the InnoDB recovery time for InnoDB.
Page 7
Page 8
Pre-Requisites
MySQL 5.5 & InnoDB must be used for the database (note that MyISAM is not crash-safe and so
failover may result in a corrupt database)
Windows Server 2008 R2
Redundant network connections between nodes and storage
WSFC cluster validation must pass
iSCSI or FCAL SAN should be used for the shared storage
Page 9
Page 10
Page 11
Page 12
Page 13
Copy From
C:\Program Files\MySQL\MySQL Server 5.5
C:\ProgramData\MySQL\MySQL
Server
5.5\data
Copy To
F:\MySQL Server 5.5
F:\MySQL Data
This assumes that the same drive letters are used on the 2 servers if this is not possible then the drive
letter will be different in the 2 configuration files
Page 14
Page 15
Page 16
Page 17
Page 18
To check that the MySQL replication is working, the table can be checked on the slave:
192.168.2.1 slave> USE clusterdb;
192.168.2.1 slave> SELECT * FROM simples;
+----+
| id |
+----+
| 1 |
+----+
The MySQL service was initially created on ws1 but it can be forced to migrate to ws3 by right-clicking on the
service and selecting Move this service or application to another node as shown in Figure 22.
Page 19
Page 20
To see how the MySQL slave copes insert a new row into the clustered MySQL then check the slave.
Failover again to ws1, and add another row. As you can see, the slave will automatically reconnect to the
clustered MySQL and resume replication right where it left off.:
mysql> INSERT INTO SIMPLES VALUES (2);
No connection. Trying to reconnect...
Connection id:
1
Current database: clusterdb
Query OK, 1 row affected (0.13 sec)
192.168.2.1 slave> SELECT * FROM simples;
+----+
| id |
+----+
| 1 |
+----+
192.168.2.1 slave> SHOW SLAVE STATUS\G
*************************** 1. row ***************************
Slave_IO_State: Reconnecting after a failed master event read
Master_Host: 192.168.2.18
Master_User: repl_user
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: clusterdv-bin.000007
Read_Master_Log_Pos: 107
Relay_Log_File: clusterdb-slave-relay-bin.000011
Relay_Log_Pos: 257
Relay_Master_Log_File: clusterdv-bin.000007
Slave_IO_Running: Connecting
Slave_SQL_Running: Yes
192.168.2.1 slave> SHOW SLAVE STATUS\G
*************************** 1.
Slave_IO_State:
Master_Host:
Master_User:
Master_Port:
Connect_Retry:
row ***************************
Waiting for master to send event
192.168.2.18
repl_user
3306
60
Page 21
isolated. This is known as the split-brain problem. The default rule is that if 2 out of 3 of the 2 hosts and 1
quorum disk can access each other then theyre allowed to continue and provide the service otherwise the
service is halted. As an example, if the service, as well as the quorum and MySQL disks are owned by ws1
and ws1 loses both of its network connections (one to the iSCSI storage and one to the cluster) then the
service and the MySQL disk are automatically failed over to ws3 the service is allowed to continue as both
ws3 and the failed-over quorum disk are still available (2 votes out of 3 is a majority). Note that when the
network connections are restored, ws1
automatically rejoins the Cluster as the
new passive node.
The high availability of a sharedeverything cluster is highly dependent
on the level of availability of the shared
storage. If for example, the Microsoft
iSCSI Software Target tool is used to
disable the MySQL Disk (Figure 24)
then the MySQL service is lost until the
shared disk is enabled again. If higher
levels of availability are required than
provided by Windows clustering then
MySQL Cluster is an alternative to
consider.
Page 22
Conclusion
More users develop and deploy and MySQL on Windows than any other single platform. Enhancements in
MySQL 5.5 increased performance by over 5x compared to previous MySQL releases. With certification for
Windows Server Failover Clustering, MySQL can now be deployed to support business critical workloads
demanding high availability, enabling organizations to better meet demanding service levels while also
reducing TCO and eliminating single vendor lock-in.
Additional Resources
Page 23