DRBD Installation and Configuration
Setting Up the Basics on Your Servers (server1 , server2)
Once you've made sure your machines are ready, you can go ahead and create an equal-sized partition on both machines. At this stage, you DO NOT need to create a filesystem on that partition and mount to OS, because you will do that only once it is running mirrored over DRBD.
The next step after partitioning is getting the packages for Heartbeat version 1.2+ and DRBD version 0.8+ installed and the DRBD kernel module compiled. If you can get these prepackaged for your distribution, it will probably be easier,
[root@server1,2 ~]# yum install heartbeat
but if not, you can download them from
[root@server1,2 ~]# rpm -ivh ***.rpm
Now, Set up the LAN cable for HA and cross cable for DRBD for server1,2 netwotk. Then, go to both server /etc/hosts file and add a couple lines, one for your primary and another for your secondary redundant server. Call one server1, the other server2, and finally, call one mail, and set the IP addresses appropriately. It should look something like this:
[root@server1,2 ~]# vi /etc/hosts
(Skip this part if you use HA to auto mount /dev/drbd0 to /data)
[root@server1,2 ~]# vi /etc/fstab
Editing server1 and server2 DRBD configuration:
Now let's start the DRBD daemon on both nodes, but before this we want to start DRBD daemon on the next reboot. For this we will use the command chkconfig on both nodes.
[root@server1,2 ~]# drbdadm create-md drbd0
Device size would be truncated, which would corrupt data and result in 'access beyond end of device' errors. You need to either * use external meta data (recommended) * shrink that filesystem first * zero out the device (destroy the filesystem) Operation refused.Use this command to DESTROY the device which is mounted for drbd
dd if=/dev/zero bs=1M count=1 of=/dev/sdXYZ; sync
Set primary node for server1 and secondary node for server2:
Make server1 to drbd primary node:
Make server2 to drbd secondary node:
After drbd sync between server1 and server2 is completed (cat /proc/drbd).
Then make FileSystem of /dev/drbd0 (to avoid the problem of meta-data for first time.)
Then mount /dev/drbd0 to /data in primary node server1
[root@server1 ~]# mkfs.ext3 /dev/drbd0
If you use HA to control DRBD , first dismount /dev/drbd0 before you done in step4 and 'chkconfig httpd off'
[root@server1 ~]# umount /dev/drbd0
But little different in /etc/ha.d/haresources: (if you have services qmail,httpd,mysqld)
[root@server1,2 ~]# vi /etc/ha.d/haresources
[root@server1,2 ~]# vi /etc/ha.d/resource.d/drbddisk
[root@server1 ~]# df -h
After all, HA and DRBD is running and install successful!
How to test change server2 to primary node and mount /dev/drbd0 manually??
(Skip this part if you use HA to auto take over and mount /dev/drbd0 to /data)
Umount DRBD's block device and make the primary node "secondary":
[root@server1 ~]# umount /data
[root@server2 ~]# drbdsetup /dev/drbd0 primary -o
Server is hosted by Alanstudio
Linux Operating System
Recommend screen resolution 1024 x 768 / IE / FireFox
Alan Studio © 2007 by Alan Cheung Hin Lun. All rights reserved.