Once the "/etc/drbd.conf" file is in place on both nodes, it's easy to create the DRBD device. On both nodes run the commanddrbdadm create-md vs(This assumes that in your drbd.conf file, you called this resource "vs". If not, use the name you gave it, or use "all" to create ALL drbd devices in the "drbd.conf" file.) If you have included the "drbd-peer-outdater" line in your drbd.conf file, the output will tell you that you need to change the ownership and permissions of some of the drbdadm programs so that heartbeat can use them to mark one side of the DRBD cluster as outdated. You can follow those instructions now, or we'll actually make those changes when we get to the Setup Heartbeat page. Then on both nodes, rundrbdadm up vs Now DRBD should be active and the nodes should be talking to one another. You can check the status of your DRBD device by running "cat /proc/drbd". Here's what it will look like: node1:~# cat /proc/drbd version: 8.0.14 (api:86/proto:86) GIT-hash: bb447522fc9a87d0069b7e14f0234911ebdab0f7 build by phil@fat-tyre, 2008-11-12 16:40:33 1: cs:Connected st:Secondary/Secondary ds:Inconsistent/Inconsistent C r--- ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 resync: used:0/0 hits:0 misses:0 starving:0 dirty:0 changed:0 act_log: used:0/0 hits:0 misses:0 starving:0 dirty:0 changed:0 Here's the important line:1: cs:Connected st:Secondary/Secondary ds:Inconsistent/Inconsistent C r---That tells us that:
- DRBD is "Connected" (the "cs" item)
- The "State" (the "st" item) of both sides is now "Secondary". The first item is the state of the local device and the second is the state of the other side of the cluster.
- The "Disk State" (the "ds" item) of both nodes is "Inconsistent". That's because we just created it and so DRBD doesn't know which side has the "good" data. (Like the "st" item, the first state is the local node, the second is the remote node.)
Now we need to make one side of the cluster "Primary" in order to use it. You cannot mount or use a DRBD device unless its "State" (also called "Role" in later versions of DRBD) is "Primary". Normally, you make one node of the cluster "Primary" simply by running "drbdadm primary vs" on that node. But that won't work now (in a newly created device) because the data has to be in the "UpToDate" state before DRBD will allow you make it Primary. So since this is the initial setup of the device and neither side has any data, we simply pick one node to be primary and tell DRBD to make that node primary and the other node secondary regardless of the state of the data. So on the node you want to be primary, run drbdadm -- --overwrite-data-of-peer primary vs This will start DRBD doing a full sync of the Primary to the Secondary. If you look at "/proc/drbd" on the node you made primary, now you'll see that it says 1: cs:SyncSource st:Primary/Secondary ds:UpToDate/Inconsistent C r---There will also be lines showing the status of the sync. If you're a glutton for punishment, you can "watch" the sync by running watch cat /proc/drbd At this point the Primary node is active and can be used, even while it's syncing. I'm normally a "coward" and let the sync complete before I do any more steps, but you don't have to. You can move forward immediately if you wish. Once the sync is done, then "/proc/drbd" on the Primary will show you1: cs:Connected st:Primary/Secondary ds:UpToDate/UpToDate C r---And on the Secondary it will show you1: cs:Connected st:Secondary/Primary ds:UpToDate/UpToDate C r--- The last step is to create a filesystem on the newly created DRBD device. At this point, the DRBD device can be used just like any other block device on the system. Our DRBD device is "/dev/drbd0", so to create an ext3 partition on that device we runmkfs.ext3 /dev/drbd0Since everything that happens on the Primary node is automatically replicated to the Secondary by DRBD, the filesystem will be created on both nodes automatically.