{"id":1396,"date":"2019-08-08T12:56:47","date_gmt":"2019-08-08T17:56:47","guid":{"rendered":"http:\/\/blog.ls-al.com\/?p=1396"},"modified":"2019-08-08T12:56:48","modified_gmt":"2019-08-08T17:56:48","slug":"poc-of-drdb-replication","status":"publish","type":"post","link":"https:\/\/blog.ls-al.com\/poc-of-drdb-replication\/","title":{"rendered":"POC of drdb replication"},"content":{"rendered":"\n

My notes of a quick drdb test...<\/p>\n\n\n\n

The Distributed Replicated Block Device (DRBD) provides a networked version of data mirroring, classified under the redundant array of independent disks (RAID) taxonomy as RAID-1.<\/p>\n\n\n\n

Showing status, add a file and check target\u2026<\/p>\n\n\n\n

After initial sync:<\/strong><\/p>\n\n\n

\n[root@drdb01 ~]# drbdadm status test\ntest role:Primary\n  disk:UpToDate\n  peer role:Secondary\n    replication:Established peer-disk:UpToDate\n\n[root@drdb02 ~]# drbdadm status test\ntest role:Secondary\n  disk:UpToDate\n  peer role:Primary\n    replication:Established peer-disk:UpToDate\n<\/pre><\/div>\n\n\n

Create filesystem and some data:<\/strong><\/p>\n\n\n

\n[root@drdb01 ~]# mkfs -t ext4 \/dev\/drbd0\n\n[root@drdb01 ~]# mkdir -p \/mnt\/DRDB_PRI\n[root@drdb01 ~]# mount \/dev\/drbd0 \/mnt\/DRDB_PRI\n[root@drdb01 ~]# cd \/mnt\/DRDB_PRI\n[root@drdb01 DRDB_PRI]# ls -l\ntotal 16\ndrwx------. 2 root root 16384 Aug  6 10:12 lost+found\n\n[root@drdb01 DRDB_PRI]# yum install wget\n\n[root@drdb01 DRDB_PRI]# wget https:\/\/osdn.net\/projects\/systemrescuecd\/storage\/releases\/6.0.3\/systemrescuecd-6.0.3.iso\n2019-08-06 10:18:13 (4.61 MB\/s) - \u2018systemrescuecd-6.0.3.iso\u2019 saved [881852416\/881852416]\n\n[root@drdb01 DRDB_PRI]# ls -lh\ntotal 842M\ndrwx------. 2 root root  16K Aug  6 10:12 lost+found\n-rw-r--r--. 1 root root 841M Apr 14 08:52 systemrescuecd-6.0.3.iso\n<\/pre><\/div>\n\n\n

Switch roles and check SECONDARY:<\/strong><\/p>\n\n\n

\n[root@drdb01 ~]# umount \/mnt\/DRDB_PRI\n[root@drdb01 ~]# drbdadm secondary test\n\n[root@drdb02 ~]# drbdadm primary test\n[root@drdb02 ~]# mkdir -p \/mnt\/DRDB_SEC\n[root@drdb02 ~]# mount \/dev\/drbd0 \/mnt\/DRDB_SEC\n[root@drdb02 ~]# cd \/mnt\/DRDB_SEC\n[root@drdb02 DRDB_SEC]# ls -lh\ntotal 842M\ndrwx------. 2 root root  16K Aug  6 10:12 lost+found\n-rw-r--r--. 1 root root 841M Apr 14 08:52 systemrescuecd-6.0.3.iso\n\n<\/pre><\/div>\n\n\n

Switch roles back:<\/strong><\/p>\n\n\n

\n[root@drdb02 DRDB_SEC]# cd\n[root@drdb02 ~]# umount \/mnt\/DRDB_SEC\n[root@drdb02 ~]# drbdadm secondary test\n\n[root@drdb01 ~]# drbdadm primary test\n[root@drdb01 ~]# mount \/dev\/drbd0 \/mnt\/DRDB_PRI\n<\/pre><\/div>\n\n\n

Detailed steps below of how we got to above test\u2026<\/p>\n\n\n\n

Node 1 Setup and start initial sync:<\/strong><\/p>\n\n\n

\nrrosso\u00a0\ue0b0\u00a0~\u00a0\ue0b0\u00a0ssh root@192.168.1.95\n[root@drdb01 ~]# rpm --import https:\/\/www.elrepo.org\/RPM-GPG-KEY-elrepo.org\n\n[root@drdb01 ~]# rpm -Uvh http:\/\/www.elrepo.org\/elrepo-release-7.0-3.el7.elrepo.noarch.rpm\n\n[root@drdb01 ~]# yum install -y kmod-drbd84 drbd84-utils\n\n[root@drdb01 ~]# firewall-cmd --permanent --add-rich-rule='rule family="ipv4"  source address="192.168.1.96" port port="7789" protocol="tcp" accept'\nsuccess\n\n[root@drdb01 ~]# firewall-cmd --reload\nsuccess\n\n[root@drdb01 ~]# yum install policycoreutils-python\n\n[root@drdb01 ~]# semanage permissive -a drbd_t\n\n[root@drdb01 ~]# df -h\nFilesystem           Size  Used Avail Use% Mounted on\n\/dev\/mapper\/cl-root  6.2G  1.2G  5.1G  20% \/\ndevtmpfs             990M     0  990M   0% \/dev\ntmpfs               1001M     0 1001M   0% \/dev\/shm\ntmpfs               1001M  8.4M  992M   1% \/run\ntmpfs               1001M     0 1001M   0% \/sys\/fs\/cgroup\n\/dev\/sda1           1014M  151M  864M  15% \/boot\ntmpfs                201M     0  201M   0% \/run\/user\/0\n\n[root@drdb01 ~]# init 0\n\nrrosso\u00a0\ue0b0\u00a0~\u00a0\ue0b0\u00a0255\u00a0\ue0b0\u00a0ssh root@192.168.1.95\n\n[root@drdb01 ~]# fdisk -l | grep sd\nDisk \/dev\/sda: 8589 MB, 8589934592 bytes, 16777216 sectors\n\/dev\/sda1   *        2048     2099199     1048576   83  Linux\n\/dev\/sda2         2099200    16777215     7339008   8e  Linux LVM\nDisk \/dev\/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors\n\n[root@drdb01 ~]# vi \/etc\/drbd.d\/global_common.conf \n[root@drdb01 ~]# vi \/etc\/drbd.d\/test.res\n\n[root@drdb01 ~]# uname -n\ndrdb01.localdomain\n\n** partition disk\n[root@drdb01 ~]# fdisk \/dev\/sdb\n\n[root@drdb01 ~]# vi \/etc\/drbd.d\/test.res\n\n[root@drdb01 ~]# drbdadm create-md test\ninitializing activity log\ninitializing bitmap (640 KB) to all zero\nWriting meta data...\nNew drbd meta data block successfully created.\n\n[root@drdb01 ~]# drbdadm up test\nThe server's response is:\nyou are the 18305th user to install this version\n\n[root@drdb01 ~]# vi \/etc\/drbd.d\/test.res\n\n[root@drdb01 ~]# drbdadm down test\n\n[root@drdb01 ~]# drbdadm up test\n\n[root@drdb01 ~]# drbdadm status test\ntest role:Secondary\n  disk:Inconsistent\n  peer role:Secondary\n    replication:Established peer-disk:Inconsistent\n\n[root@drdb01 ~]# drbdadm primary --force test\n[root@drdb01 ~]# drbdadm status test\ntest role:Primary\n  disk:UpToDate\n  peer role:Secondary\n    replication:SyncSource peer-disk:Inconsistent done:0.01\n\n[root@drdb01 ~]# drbdadm status test\ntest role:Primary\n  disk:UpToDate\n  peer role:Secondary\n    replication:SyncSource peer-disk:Inconsistent done:3.80\n\n[root@drdb01 ~]# drbdadm status test\ntest role:Primary\n  disk:UpToDate\n  peer role:Secondary\n    replication:SyncSource peer-disk:Inconsistent done:85.14\n\n<\/pre><\/div>\n\n\n

Node 2 setup and start initial sync:<\/strong><\/p>\n\n\n

\n\u00a0rrosso\u00a0\ue0b0\u00a0~\u00a0\ue0b0\u00a0ssh root@192.168.1.96\n\n[root@drdb01 ~]# rpm --import https:\/\/www.elrepo.org\/RPM-GPG-KEY-elrepo.org\n\n[root@drdb01 ~]# rpm -Uvh http:\/\/www.elrepo.org\/elrepo-release-7.0-3.el7.elrepo.noarch.rpm\n\n[root@drdb01 ~]# firewall-cmd --permanent --add-rich-rule='rule family="ipv4"  source address="192.168.1.95" port port="7789" protocol="tcp" accept'\nsuccess\n\n[root@drdb01 ~]# firewall-cmd --reload\nsuccess\n\n[root@drdb01 ~]# yum install policycoreutils-python\n\n[root@drdb01 ~]# semanage permissive -a drbd_t\n[root@drdb01 ~]# init 0\n\n\u00a0rrosso\u00a0\ue0b0\u00a0~\u00a0\ue0b0\u00a0255\u00a0\ue0b0\u00a0ssh root@192.168.1.96\nroot@192.168.1.96's password: \nLast login: Tue Aug  6 09:46:34 2019\n\n[root@drdb01 ~]# fdisk -l | grep sd\nDisk \/dev\/sda: 8589 MB, 8589934592 bytes, 16777216 sectors\n\/dev\/sda1   *        2048     2099199     1048576   83  Linux\n\/dev\/sda2         2099200    16777215     7339008   8e  Linux LVM\nDisk \/dev\/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors\n\n[root@drdb01 ~]# vi \/etc\/drbd.d\/global_common.conf \n[root@drdb01 ~]# vi \/etc\/drbd.d\/test.res\n\n** partition disk\n[root@drdb01 ~]# fdisk \/dev\/sdb\n\n[root@drdb01 ~]# fdisk -l | grep sd\nDisk \/dev\/sda: 8589 MB, 8589934592 bytes, 16777216 sectors\n\/dev\/sda1   *        2048     2099199     1048576   83  Linux\n\/dev\/sda2         2099200    16777215     7339008   8e  Linux LVM\nDisk \/dev\/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors\n\/dev\/sdb1            2048    41943039    20970496   83  Linux\n\n[root@drdb01 ~]# vi \/etc\/drbd.d\/test.res\n\n[root@drdb01 ~]# drbdadm create-md test\ninitializing activity log\ninitializing bitmap (640 KB) to all zero\nWriting meta data...\nNew drbd meta data block successfully created.\n\n** note I had wrong hostname because I cloned 2nd VM\n[root@drdb01 ~]# drbdadm up test\nyou are the 18306th user to install this version\ndrbd.d\/test.res:6: in resource test, on drdb01.localdomain:\n\tIP 192.168.1.95 not found on this host.\n\n[root@drdb01 ~]# vi \/etc\/drbd.d\/test.res\n\n[root@drdb01 ~]# uname -a\nLinux drdb01.localdomain 3.10.0-957.27.2.el7.x86_64 #1 SMP Mon Jul 29 17:46:05 UTC 2019 x86_64 x86_64 x86_64 GNU\/Linux\n\n[root@drdb01 ~]# vi \/etc\/hostname \n[root@drdb01 ~]# vi \/etc\/hosts\n[root@drdb01 ~]# reboot\n\n\u00a0rrosso\u00a0\ue0b0\u00a0~\u00a0\ue0b0\u00a0255\u00a0\ue0b0\u00a0ssh root@192.168.1.96\n\n[root@drdb02 ~]# uname -a\nLinux drdb02.localdomain 3.10.0-957.27.2.el7.x86_64 #1 SMP Mon Jul 29 17:46:05 UTC 2019 x86_64 x86_64 x86_64 GNU\/Linux\n\n[root@drdb02 ~]# drbdadm up test\n\n[root@drdb02 ~]# drbdadm status test\ntest role:Secondary\n  disk:Inconsistent\n  peer role:Secondary\n    replication:Established peer-disk:Inconsistent\n\n[root@drdb02 ~]# drbdadm status test\ntest role:Secondary\n  disk:Inconsistent\n  peer role:Primary\n    replication:SyncTarget peer-disk:UpToDate done:0.21\n\n[root@drdb02 ~]# drbdadm status test\ntest role:Secondary\n  disk:Inconsistent\n  peer role:Primary\n    replication:SyncTarget peer-disk:UpToDate done:82.66\n<\/pre><\/div>\n\n\n

LINKS:<\/strong><\/p>\n\n\n\n

https:\/\/www.linbit.com\/en\/disaster-recovery\/
https:\/\/www.tecmint.com\/setup-drbd-storage-replication-on-centos-7\/<\/p>\n\n\n\n

<\/p>\n","protected":false},"excerpt":{"rendered":"

My notes of a quick drdb test… The Distributed Replicated Block Device (DRBD) provides a networked version of data mirroring,<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[109],"tags":[],"class_list":["post-1396","post","type-post","status-publish","format-standard","hentry","category-drdb"],"_links":{"self":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts\/1396","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/comments?post=1396"}],"version-history":[{"count":0,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts\/1396\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/media?parent=1396"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/categories?post=1396"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/tags?post=1396"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}