Vyoms OneStopTesting.com - Testing EBooks, Tutorials, Articles, Jobs, Training Institutes etc.
OneStopGate.com - Gate EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopMBA.com - MBA EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopIAS.com - IAS EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopSAP.com - SAP EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopGRE.com - of GRE EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
Bookmark and Share Rss Feeds

DRBD and MySQL - Excellent Low-cost HA Solution | Articles | Recent Articles | News Article | Interesting Articles | Technology Articles | Articles On Education | Articles On Corporate | Company Articles | College Articles | Articles on Recession
Sponsored Ads
Hot Jobs
Fresher Jobs
Experienced Jobs
Government Jobs
Walkin Jobs
Placement Section
Company Profiles
Interview Questions
Placement Papers
Resources @ VYOMS
Companies In India
Consultants In India
Colleges In India
Exams In India
Latest Results
Notifications In India
Call Centers In India
Training Institutes In India
Job Communities In India
Courses In India
Jobs by Keyskills
Jobs by Functional Areas
Learn @ VYOMS
GATE Preparation
GRE Preparation
GMAT Preparation
IAS Preparation
SAP Preparation
Testing Preparation
MBA Preparation
News @ VYOMS
Freshers News
Job Articles
Latest News
India News Network
Interview Ebook
Get 30,000+ Interview Questions & Answers in an eBook.
Interview Success Kit - Get Success in Job Interviews
  • 30,000+ Interview Questions
  • Most Questions Answered
  • 5 FREE Bonuses
  • Free Upgrades


Wipro Technologies
Tata Consultancy Services
Cognizant Technologies

Home » Articles » DRBD and MySQL - Excellent Low-cost HA Solution

DRBD and MySQL - Excellent Low-cost HA Solution

Article Posted On Date : Friday, January 15, 2010

DRBD and MySQL - Excellent Low-cost HA Solution


DRBD is a Linux project to provide a real-time distributed filesystem. Although it has some clustering support, it's not really a true clustered filesystem like OCFS2 or GFS2. What it provides is a mirrored copy of a block device across a network.
HA with MySQL Replication

MySQL high availability is often implemented with its in-built replication technology. The standard master-slave configuration provides one database as the primary, receiving all write traffic that is all changes to data. Read traffic, i.e. SELECT queries, can be sent to the primary or to the replicated slaves. Transactions flow on the primary database into its binary log. The slave keeps a watchful eye on the primary, copying new transactions into its own relay log. Keep in mind until 5.1 this involved copying the *actual* SQL statements albeit in binary form. Once they make it to the slave database, another thread then applies those SQL statements in a serial fashion thus theoretically keeping that slave in the same state as the primary.

The trouble comes when your replication stops, and the error log shows some funny error about duplicate keys or failed primary key constraint. How's that possible? If all the same transactions are being applied in serial, the two databases should never have a case like this. Strange indeed. It turns out that as we all know, a lot of things can happen when a query executes to interrupt it or cause otherwise anomalous behavior. Mixing InnoDB and MyISAM tables (i.e. transactional and non-transactional) is one way to get into trouble, but there are others. Various functions are non-deterministic in MySQL, meaning they won't behave exactly the same when run twice. Time functions & user functions are a few examples.

So the upshot of all of this is that MySQL replication is not at all bulletproof out of the box, and most master slave setups inevitably have data differences between master and slave. There are some checksum tools that can be used to alleviate these problems, and of course, there is a list of non-deterministic functions, so you can audit your application to make it completely compliant with MySQL replication. However, that is a lot of work, but it can certainly be done.
What is DRBD?

Acronyms are typically cryptic in computer science, and DRBD is no exception. The initials stand for Distributed Replicated Block Device. What does that mean exactly? Well the file system is part of your operating system, and it is a layer between the OS and the disk hardware, either a single disk or a disk I/O subsystem such as a RAID. It is exposed to the OS as a block device, and data is read and written in discrete chunks called blocks. The OS issues requests via the filesystem.

Ok, enough about filesystems, and block devices, what's DRBD then? Well it allows you to have a mirror copy of a block device in real-time. Impressive, right? Since it's a block device, you'll use it with a filesystem such as ext2 or one of the journaling filesystems ext3, reiserFS or JFS etc. Keep in mind though that it isn't a true clustered filesystem. It's primarily built to have one side active at a time. As of version 8 it *can* be used with clustered filesystems such as OCFS2 and GFS2. In these cases where you have both sides mounted as primaries, your clustered filesystem has to figure out which blocks are invalid and need to be synced and in which direction. These filesystems can be slow, so keep that in mind if you're leaning in that direction.
MySQL and DRBD Working Together

So we see some of the limitations of doing high availability using basic out-of-the box MySQL replication. So how can DRBD help? Well it turns out that MySQL interacts with the disk through the filesystem, so a MySQL database can sit on top of one of these magical distributed or mirrored block devices that DRBD provides. So it can effectively keep a complete copy of your database for you on another machine available when and if you need it.

In order to set this up for most production setups you would want to have your data directory on the mirrored block device but have your configuration and log files elsewhere. That would allow you to have a slightly different setup on both servers, or have separate logfiles. There are many reasons to want to separate those out. The main thing is that your core database files, innodb tablespace files, and binary logs are on the DRBD volume.

Want to throw in automatic failover? That's where the heartbeat project comes in. Heartbeat is the smarts behind deciding if a node is down. When it determines that one is down, it will run all the steps you define, to bring the other node back up and ready.

DRBD is definitely exciting technology, and a great match with MySQL. It provides a more bulletproof HA solution for MySQL, when you want to do seamless failover. It requires less maintenance, and avoids many of the headaches of in-built MySQL replication that every seasoned MySQL DBA has had to deal with.

In next month's article, we'll discuss how to setup DRBD with MySQL. We'll show you how to build a couple of virtual machines, install DRBD from RPM, add a simple configuration, and start it up. Then we'll take you through creating a simple MySQL database, and finally perform a few tests to illustrate the failover feature and its effectiveness.

Sponsored Ads

Interview Questions
HR Interview Questions
Testing Interview Questions
SAP Interview Questions
Business Intelligence Interview Questions
Call Center Interview Questions


Clipper Interview Questions
DBA Interview Questions
Firebird Interview Questions
Hierarchical Interview Questions
Informix Interview Questions
Microsoft Access Interview Questions
MS SqlServer Interview Questions
MYSQL Interview Questions
Network Interview Questions
Object Relational Interview Questions
PL/SQL Interview Questions
PostgreSQL Interview Questions
Progress Interview Questions
Relational Interview Questions
SQL Interview Questions
SQL Server Interview Questions
Stored Procedures Interview Questions
Sybase Interview Questions
Teradata Interview Questions

Microsof Technologies

.Net Database Interview Questions
.Net Deployement Interview Questions
ADO.NET Interview Questions
ADO.NET 2.0 Interview Questions
Architecture Interview Questions
ASP Interview Questions
ASP.NET Interview Questions
ASP.NET 2.0 Interview Questions
C# Interview Questions
Csharp Interview Questions
DataGrid Interview Questions
DotNet Interview Questions
Microsoft Basics Interview Questions
Microsoft.NET Interview Questions
Microsoft.NET 2.0 Interview Questions
Share Point Interview Questions
Silverlight Interview Questions
VB.NET Interview Questions
VC++ Interview Questions
Visual Basic Interview Questions

Java / J2EE

Applet Interview Questions
Core Java Interview Questions
Eclipse Interview Questions
EJB Interview Questions
Hibernate Interview Questions
J2ME Interview Questions
J2SE Interview Questions
Java Interview Questions
Java Beans Interview Questions
Java Patterns Interview Questions
Java Security Interview Questions
Java Swing Interview Questions
JBOSS Interview Questions
JDBC Interview Questions
JMS Interview Questions
JSF Interview Questions
JSP Interview Questions
RMI Interview Questions
Servlet Interview Questions
Socket Programming Interview Questions
Springs Interview Questions
Struts Interview Questions
Web Sphere Interview Questions

Programming Languages

C Interview Questions
C++ Interview Questions
CGI Interview Questions
Delphi Interview Questions
Fortran Interview Questions
ILU Interview Questions
LISP Interview Questions
Pascal Interview Questions
Perl Interview Questions
PHP Interview Questions
Ruby Interview Questions
Signature Interview Questions
UML Interview Questions
VBA Interview Questions
Windows Interview Questions
Mainframe Interview Questions

Copyright © 2001-2023 Vyoms.com. All Rights Reserved. Home | About Us | Advertise With Vyoms.com | Jobs | Contact Us | Feedback | Link to Us | Privacy Policy | Terms & Conditions
Placement Papers | Get Your Free Website | IAS Preparation | C++ Interview Questions | C Interview Questions | Report a Bug | Romantic Shayari | CAT 2023

Fresher Jobs | Experienced Jobs | Government Jobs | Walkin Jobs | Company Profiles | Interview Questions | Placement Papers | Companies In India | Consultants In India | Colleges In India | Exams In India | Latest Results | Notifications In India | Call Centers In India | Training Institutes In India | Job Communities In India | Courses In India | Jobs by Keyskills | Jobs by Functional Areas

Testing Articles | Testing Books | Testing Certifications | Testing FAQs | Testing Downloads | Testing Interview Questions | Testing Jobs | Testing Training Institutes

Gate Articles | Gate Books | Gate Colleges | Gate Downloads | Gate Faqs | Gate Jobs | Gate News | Gate Sample Papers | Gate Training Institutes

MBA Articles | MBA Books | MBA Case Studies | MBA Business Schools | MBA Current Affairs | MBA Downloads | MBA Events | MBA Notifications | MBA FAQs | MBA Jobs
MBA Job Consultants | MBA News | MBA Results | MBA Courses | MBA Sample Papers | MBA Interview Questions | MBA Training Institutes

GRE Articles | GRE Books | GRE Colleges | GRE Downloads | GRE Events | GRE FAQs | GRE News | GRE Training Institutes | GRE Sample Papers

IAS Articles | IAS Books | IAS Current Affairs | IAS Downloads | IAS Events | IAS FAQs | IAS News | IAS Notifications | IAS UPSC Jobs | IAS Previous Question Papers
IAS Results | IAS Sample Papers | IAS Interview Questions | IAS Training Institutes | IAS Toppers Interview

SAP Articles | SAP Books | SAP Certifications | SAP Companies | SAP Study Materials | SAP Events | SAP FAQs | SAP Jobs | SAP Job Consultants
SAP Links | SAP News | SAP Sample Papers | SAP Interview Questions | SAP Training Institutes |

Copyright ©2001-2023 Vyoms.com, All Rights Reserved.
Disclaimer: VYOMS.com has taken all reasonable steps to ensure that information on this site is authentic. Applicants are advised to research bonafides of advertisers independently. VYOMS.com shall not have any responsibility in this regard.