Install and configure DRDB for network filesystem replication on Debian 8 - Page 3

DRDB with OCFS2 filesystem

In the previous scenario there's a little problem: if you mount both filesystems, you can't see the changes, until you remount the partition, and this in some situation may be a problem, so instead of ext4, you can use ocfs2 filesystem.

First of all be sure to have /dev/drbd1 unmounted, so for security on both servers, run:

umount /var/www

Now we install the ocfs2 utilities on both nodes to create our distributed filesystem:

apt-get install ocfs2-tools

After that, we can create the ocfs2 filesystem with the command:

[email protected]:/var/www# mkfs -t ocfs2 -N 2 -L ocfs2_drbd1 /dev/drbd1

The output should be something similare to this:

[email protected]:/var/www# mkfs -t ocfs2 -N 2 -L ocfs2_drbd1 /dev/drbd1
mkfs.ocfs2 1.6.4
Cluster stack: classic o2cb
/dev/drbd1 is mounted; will not make a ocfs2 volume here!
[email protected]:/var/www# cd
[email protected]:~# umount /var/www/
[email protected]:~# mkfs -t ocfs2 -N 2 -L ocfs2_drbd1 /dev/drbd1
mkfs.ocfs2 1.6.4
Cluster stack: classic o2cb
Label: ocfs2_drbd1
Features: sparse backup-super unwritten inline-data strict-journal-super xattr
Block size: 4096 (12 bits)
Cluster size: 4096 (12 bits)
Volume size: 5368508416 (1310671 clusters) (1310671 blocks)
Cluster groups: 41 (tail covers 20431 clusters, rest cover 32256 clusters)
Extent allocator size: 4194304 (1 groups)
Journal size: 67108864
Node slots: 2
Creating bitmaps: done
Initializing superblock: done
Writing system files: done
Writing superblock: done
Writing backup superblock: 2 block(s)
Formatting Journals: done
Growing extent allocator: done
Formatting slot map: done
Formatting quota files: done
Writing lost+found: done
mkfs.ocfs2 successful

Now we use the native features of ocfs2 to manage the distributed filesystem.

Let's start edit /etc/ocfs2/cluster.conf on boths node and add the following:

node:
ip_port = 7777
ip_address = 192.168.152.100
number = 0
name = mysql1.local.vm
cluster = ocfs2
node:
ip_port = 7777
ip_address = 192.168.152.110
number = 1
name = mysql2.local.vm
cluster = ocfs2
cluster:
node_count = 2
name = ocfs2

We have to restart the ocfs2 service. Run on both nodes this command:

/etc/init.d/o2cb restart

And check the status is ok like this:

[email protected]:~# /etc/init.d/o2cb status
* o2cb.service - LSB: Load O2CB cluster services at system boot.
Loaded: loaded (/etc/init.d/o2cb)
Active: active (exited) since Wed 2016-10-05 16:10:20 CEST; 23s ago
Process: 2767 ExecStop=/etc/init.d/o2cb stop (code=exited, status=0/SUCCESS)
Process: 2793 ExecStart=/etc/init.d/o2cb start (code=exited, status=0/SUCCESS)
Oct 05 16:10:20 mysql1.local.vm systemd[1]: Starting LSB: Load O2CB cluster services at system boot....
Oct 05 16:10:20 mysql1.local.vm o2cb[2793]: Loading filesystem "configfs": OK
Oct 05 16:10:20 mysql1.local.vm o2cb[2793]: Loading stack plugin "o2cb": OK
Oct 05 16:10:20 mysql1.local.vm o2cb[2793]: Loading filesystem "ocfs2_dlmfs": OK
Oct 05 16:10:20 mysql1.local.vm o2cb[2793]: Creating directory '/dlm': OK
Oct 05 16:10:20 mysql1.local.vm o2cb[2793]: Mounting ocfs2_dlmfs filesystem at /dlm: OK
Oct 05 16:10:20 mysql1.local.vm o2cb[2793]: Setting cluster stack "o2cb": OK
Oct 05 16:10:20 mysql1.local.vm o2cb[2793]: Starting O2CB cluster ocfs2: OK
Oct 05 16:10:20 mysql1.local.vm systemd[1]: Started LSB: Load O2CB cluster services at system boot..

And now you can do the magic and mount disk on both servers:

[email protected]:~# mount -t ocfs2 /dev/drbd1 /var/www/

[email protected]:~# mount -t ocfs2 /dev/drbd1 /var/www/

And try to create the file on both servers:

[email protected]:~# touch /var/www/mysql1.txt

[email protected]:~# touch /var/www/mysql2.txt

You can check that you see both files:

[email protected]:~# ls -al /var/www/
totale 4
drwxr-xr-x 3 root root 3896 ott 5 16:20 .
drwxr-xr-x 12 root root 4096 ott 5 12:25 ..
drwxr-xr-x 2 root root 3896 ott 5 15:55 lost+found
-rw-r--r-- 1 root root 0 ott 5 16:20 mysql1.txt
-rw-r--r-- 1 root root 0 ott 5 16:20 mysql2.txt

[email protected]:~# ls -al /var/www/
totale 4
drwxr-xr-x 3 root root 3896 ott 5 16:20 .
drwxr-xr-x 12 root root 4096 ott 5 12:26 ..
drwxr-xr-x 2 root root 3896 ott 5 15:55 lost+found
-rw-r--r-- 1 root root 0 ott 5 16:20 mysql1.txt
-rw-r--r-- 1 root root 0 ott 5 16:20 mysql2.txt

Performance

You can do some performance tests to check the speed of the configuration. In my case, i'll get those results with a virtual machine on my PC. On a real server, the speed will be much higher.

First, install ioping, to test the performance on random read.

apt-get install ioping

Then run the test:

[email protected]:cd /var/www
[email protected]:/var/www# ioping -R .
--- . (ocfs2 /dev/drbd1) ioping statistics ---
49.3 k requests completed in 3.00 s, 17.1 k iops, 66.7 MiB/s
min/avg/max/mdev = 43 us / 58 us / 8.41 ms / 64 us

66,7 MiB/s on a random read is very very good result!!

And a sequential read:

[email protected]:/var/www# dd if=/dev/zero of=test bs=64k count=32k conv=fdatasync
32768+0 record dentro
32768+0 record fuori
2147483648 byte (2,1 GB) copiati, 34,1095 s, 63,0 MB/s

Conclusion

This tutorial could be the basis for a mirror setup of ISPConfig, create different drdb resources for /var/www and /var/vmail, should work very ver fast.

Best Practices

  • For a filesystem with a high traffic volume, use at least a dedicated network cards.
  • For network failover bond togheter at least 2 network interfaces.
  • DRBD has a lot of options to tune the configuration and the performance of nodes.
Share this page:

0 Comment(s)

Add comment

Comments

From: Matteo Temporini at: Oct 11, 2016