The scenario install and configure DRBD
Node1:
FQDN: node1.huuphan.local
HDD1: 10GB (/dev/sda1)
HDD2: 1GB (/dev/sdb1)
Node2:
FQDN: node2.huuphan.local
HDD1: 10GB (/dev/sda1)
HDD2: 1GB (/dev/sdb1)
Note: device /dev/sdb a unpartitioned for 2 node.
Selinux: disabled mode
sed -i 's/SELINUX=enforcing/SELINUX=disable/' /etc/sysconfig/selinuxTo installing NTP for two node
yum install ntp ntpdate -yTo iptables firewall to allow 7788 port
iptables -I eth1 -m state --state NEW -m tcp -p tcp --dport 7788 -j ACCEPTTo configure /etc/hosts file
service iptables save
vim /etc/hostsThe output as bellow
172.16.235.145 node1.huuphan.local node1To create /dev/sdb1 device for two node
172.16.235.146 node2.huuphan.local node2
fdisk -lThe output as bellow
fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabelInstall and configure DRBD for two node
Building a new DOS disklabel with disk identifier 0xa3977c63.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-783, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-783, default 783):
Using default value 783
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
rpm -ivh http://elrepo.org/elrepo-release-6-5.el6.elrepo.noarch.rpmTo load module drbd for two node
yum -y install drbd84-utils.x86_64 kmod-drbd84.x86_64
modprobe drbdTo verify module drbd for two node
lsmod | grep drbdThe output as bellow
drbd 372759 0
libcrc32c 1246 1 drbd
Node 1
To configure drbd.conf filecp /etc/drbd.conf /etc/drbd.conf_origThe output as bellow
cat /dev/null > /etc/drbd.conf
vim /etc/drbd.conf
global { usage-count no; }To copy /etc/drbd.conf file to node 2 usescp command
common { syncer { rate 100M; } }
resource r0 {
protocol C;
startup {
wfc-timeout 15;
degr-wfc-timeout 60;
}
net {
cram-hmac-alg sha1;
shared-secret "secret";
}
on node1.huuphan.local {
device /dev/drbd0;
disk /dev/sdb1;
address 172.16.235.145:7788;
meta-disk internal;
}
on node2.huuphan.local {
device /dev/drbd0;
disk /dev/sdb1;
address 172.16.235.146:7788;
meta-disk internal;
}
}
scp /etc/drbd.conf node2:/etc/To initiate meta data for 2 disk
drbdadm create-md r0To sync to between 2 node
/etc/init.d/drbd start
drbdadm -- --overwrite-data-of-peer primary allFrom node 2 to view status
cat /proc/drbdor
watch cat /proc/drbdThe output as bellow
Every 2,0s: cat /proc/drbd Wed Nov 30 14:44:40 2016CTRL+C if exit
version: 8.4.7-1 (api:1/proto:86-101)
GIT-hash: 3a6a769340ef93b1ba2792c6461250790795db49 build by [email protected], 2016-01-12 13:27:11
0: cs:SyncTarget ro:Secondary/Primary ds:Inconsistent/UpToDate C r-----
ns:0 nr:618496 dw:618496 dr:0 al:8 bm:0 lo:0 pe:4 ua:0 ap:0 ep:1 wo:f oos:5670692
[>...................] sync'ed: 9.9% (5536/6140)M
finish: 0:02:17 speed: 41,232 (41,232) want: 50,280 K/sec
Only to run node 1
mkfs.ext4 /dev/drbd0To assign secondary for node 1
mkdir /data
mount /dev/drbd0 /data
touch /data/test1.txt
umount /data
drbdadm secondary r0
Node 2
drbdadm primary r0The above is Primary/Secondry mode. How to Dual-Primary mode?.
cat /proc/drbd
mkdir /data
mount /dev/drbd0 /data
ls -l /data/
Some error:
mount -t ext4 /dev/drbd0 /datamount: block device /dev/drbd0 is write-protected, mounting read-only
mount: Wrong medium type
Thanks for reading How to installing and configuring DRBD My blog Zimbra Mail Server,linux,bash script,centos,linux command I hope this is useful.