Monday, September 30, 2013

DRBD Configuration

In order to configure DRBD we need to follow these simple steps.

1. Have a root access on each servers
2. Using GPARTED create partition on both servers with a capacity of at least 2.0GB. Remember to take note of the name of the partitions since were gonna use them both in the configuration.

Creating partition using GPARTED
3. After creating partitions you can now configure the drbd.conf  file. This is located in /etc/drbd.conf. You can use Vi, Gedit or anything that is comfortable to you.

NOTE : Before configuration you need to do these steps first.
3.1 Rename each servers accordingly by doing this commands on the terminal.
    a. hostname [your_hostname] (eg. hostname drbd01).
    b. edit /etc/hostname then change the value with the respective hostname you used.
3.2 Acquire each of the computer's IP address by typing IFCONFIG.

After doing this two steps we can now configure drbd.conf. Just input the values similar to the image below on both computers or on the server1 alone then using scp just copy it to the second server (tests connectivity too!). 
DRBD Configuration
As you can notice we will use the hostname, partition name and the ip address of both servers in the configuration so make you sure you have taken note of this properly.

4. After configuring drbd.conf we can now start the drbd by typing /etc/drbd.init start (you can also replace start with restart if the service is already running for the configuration to take effect). The following responses should appear as shown in the image below. Do this on both servers.

Initializing DRBD
5. After starting DRBD you need to initialize the metadata by typing sudo drbdadm create mdr0. Afterwards on server1 type sudo drbdadm -- --overwrite-data-of-peer primary all. This line of code will allow replication of data on all servers whenever the data in the PRIMARY server is modified. Type can check the connectivity of server 2 to server 1 by typing watch n1 cat /proc/drbd. This monitors the process of server1 from server2.

Monitoring server1
6. Finally we can now mount the partition we created on both servers by doing these commands.
    a. sudo mkfs.ext3 /dev/drbd0
    b. sudo mount /dev/drbd0  /srv

Mounting the partition created
7. Now that we have successfully configured DRBD we can now check if the configuration works properly. Copy any file into the partition from the Primary server and these changes should also be reflected on server2.

No comments:

Post a Comment