DRBD not working as it should


Took the plunge and ordered 2 512 servers to test the high availability tutorial, ~~[http://library.linode.com/linux-ha/ip-failover-heartbeat-pacemaker-drbd-mysql-ubuntu-10.04" target="_blank">](http://library.linode.com/linux-ha/ip-f … untu-10.04">http://library.linode.com/linux-ha/ip-failover-heartbeat-pacemaker-drbd-mysql-ubuntu-10.04](, and was going well until the end when I noticed my second node was not syncing.

A few pastebins for you:

crm_mon output - http://p.linode.com/4330 - everything working as it should

cat /proc/drbd output - http://p.linode.com/4331 - sync appears to have worked

I then checked the mounts and on node 1 it reports that the 2 images have mounted to intended location:

/dev/drbd0 /var/lib/mysql ext3 rw,relatime,errors=continue,data=writeback 0 0
/dev/drbd1 /srv/www ext3 rw,relatime,errors=continue,data=writeback 0 0

On node 2 however, they are not mounted at all.

My question is, from the tutorial, should I be performing "mkfs.ext3 /dev/drbd0" and "mkfs.ext3 /dev/drbd1" on node 2, as I get an error if I try and mount these as node1 is configured to.

Any help appreciated, feel like I'm at the last hurdle and just can't make the finish line!

4 Replies

I may be talking out of my ass here, as I have limited knowledge of DRBD, but I'm pretty sure you're not supposed to mount one filesystem on both machines at the same time. That would be very bad.

You might try forcing the slave to mount the filesystem read-only, but even then you should be careful because data could change out under the software, and that's bad.


Simultaneously mounting on two hosts requires a filesystem specially designed to deal with it, like GFS or OCFS2.

Correct. DRBD requires a failover mechanism in place to handle the mounting for you.

Sorry for bringing this up late. I've had the occasion to experiment with DRBD a couple of weeks ago.

Most of the answers to your problem may be found in the DRBD manual here: http://www.drbd.org/users-guide/.

The surface reason why you cannot mount more than one node is that DRBD only allows one node to be primary by default. To allow two nodes to be primary, you need to setup a few things:

-Specify "allow-two-primaries" in drbd.conf. See ~~[http://www.drbd.org/users-guide/s-enable-dual-primary.html" target="_blank">](http://www.drbd.org/users-guide/s-enabl … imary.html">http://www.drbd.org/users-guide/s-enable-dual-primary.html](.

-Setup both of your nodes on a cluster.

-Implement a filesystem that allows for concurrent access, such as GFS or OCFS2. See http://www.drbd.org/users-guide/ch-gfs.html and http://www.drbd.org/users-guide/ch-ocfs2.html.

If dual primaries is not a requirement (Failover versus mirror setup),

you do not need to format or partition your drive on node2, only on node1 once. DRBD will replicate the exact configuration on the disk on node2 for you. To mount DRBD on node2, you must do the following:

-Unmount drbd on node1

-Place resource on node1 as secondary: sudo drbdadm secondary all

-Place resource on node2 as primary: sudo drbdadm primary all

-Mount drbd on node2

If you wish for the process to be automated, you should check out on monitoring software such as Heartbeat or Pacemaker. Pacemaker is less old-school, but I personally went Heartbeat since I only needed a quick way of manually switching MySQL/Apache/IP Aliasing over to the failover node whenever node1 crashes and doesn't turn back on.

Hope this helps anyone with a similar problem as well.


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct