1 The Linux machine should better has second disk, because we don’t want to sync the system partition.
2 The partition DRBD used to sync should have same size.
3 The partition DRBD used must be not mounted arbitrarily, because we need to mount the logical device of DRBD not the physical disk.
This step will build the RPM package from source code. It requires that the CPP compiler is installed on the machine.
1 Download the source code .tar.gz from http://oss.linbit.com/drbd/ , or if the Linux machine can connect to the internet, use “wget” down the source code “wget http://oss.linbit.com/drbd/8.3/drbd-8.3.10.tar.gz ”,
####################################################
[root@rh56 etc]# wget http://oss.linbit.com/drbd/8.3/drbd-8.3.10.tar.gz
--2011-06-22 23:35:39-- http://oss.linbit.com/drbd/8.3/drbd-8.3.10.tar.gz
Resolving oss.linbit.com... 212.69.161.111
Connecting to oss.linbit.com|212.69.161.111|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 521798 (510K) [application/x-gzip]
Saving to: `drbd-8.3.10.tar.gz'
100%[========================================================================================================================================>] 521,798 51.7K/s in 14s
2011-06-22 23:35:56 (35.3 KB/s) - `drbd-8.3.10.tar.gz' saved [521798/521798]
####################################################
2 Extract the source package, go to the extraction dir, execute “./configure”.
####################################################
[root@rh56 drbd-8.3.10]# ./config
-bash: ./config: No such file or directory
[root@rh56 drbd-8.3.10]# ./config
config.status configure
[root@rh56 drbd-8.3.10]# ./configure
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether ln -s works... yes
checking for sed... /bin/sed
checking for grep... /bin/grep
checking for flex... /usr/bin/flex
checking for rpmbuild... /usr/bin/rpmbuild
checking for xsltproc... /usr/bin/xsltproc
checking for tar... /bin/tar
checking for git... no
checking for dpkg-buildpackage... no
checking for udevadm... false
checking for udevinfo... /usr/bin/udevinfo
configure: WARNING: No dpkg-buildpackage found, building Debian packages is disabled.
configure: WARNING: Cannot update buildtag without git. You may safely ignore this warning when building from a tarball.
checking for /etc/gentoo-release... no
checking for /etc/redhat-release... yes
checking for /etc/slackware-version... no
checking for /etc/debian_version... no
checking for /etc/SuSE-release... no
configure: configured for Red Hat (includes Fedora, RHEL, CentOS).
checking for /etc/fedora-release... no
configure: creating ./config.status
config.status: creating Makefile
config.status: creating user/Makefile
config.status: creating scripts/Makefile
config.status: creating documentation/Makefile
config.status: creating user/config.h
config.status: user/config.h is unchanged
[root@rh56 drbd-8.3.10]#
#########################################################
3 Execute “make rpm” and “make km-rpm” if the configuration is successful.
######################not full log############################
You have now:
/usr/src/redhat/RPMS/i386/drbd-utils-8.3.10-1.i386.rpm
/usr/src/redhat/RPMS/i386/drbd-debuginfo-8.3.10-1.i386.rpm
/usr/src/redhat/RPMS/i386/drbd-bash-completion-8.3.10-1.i386.rpm
/usr/src/redhat/RPMS/i386/drbd-8.3.10-1.i386.rpm
/usr/src/redhat/RPMS/i386/drbd-xen-8.3.10-1.i386.rpm
/usr/src/redhat/RPMS/i386/drbd-heartbeat-8.3.10-1.i386.rpm
/usr/src/redhat/RPMS/i386/drbd-pacemaker-8.3.10-1.i386.rpm
/usr/src/redhat/RPMS/i386/drbd-km-debuginfo-8.3.10-1.i386.rpm
/usr/src/redhat/RPMS/i386/drbd-km-2.6.18_238.el5-8.3.10-1.i386.rpm
/usr/src/redhat/RPMS/i386/drbd-udev-8.3.10-1.i386.rpm
[root@rh56 drbd-8.3.10]#
#########################################################
4 Go to the /usr/src/redhat/RPMS/i386 dir, execute “rpm –i all” to install all rpm packages.
5 Edit the DRBD configuration file, /etc/drbd.conf to following,
global { usage-count yes; } common { syncer { rate 100M; } } resource r0 { protocol A; net { cram-hmac-alg sha1; shared-secret "cedrdb"; } on rh56 { device /dev/drbd1; # the logical device, which DRBD used disk /dev/sdb1;# the physical disk address 192.168.70.253:7789; meta-disk internal; } on cerh564 { device /dev/drbd1; disk /dev/sdb1; address 192.168.70.251:7789; meta-disk internal; } } |
6 Do the same thing on another machine.
1 Execute “drbdadm create-md r0” to create the resource.
2 Execute “/etc/init.d/drbd start” to start the drbd.
3 “drbdadm -- --overwrite-data-of-peer primary r0” to change the machine to the primary machine.
4 “mount /dev/drbd1 /drbdtest” to mount the DRBD device.
5 Execute “cat /proc/drbd” to overview the status of the DRBD.
6 “drbdadm secondary r0” will change the node to secondary, this command must executed after umount the /dev/drbd1.
7 Make some file to dir /drbdtest on the primary node, then change the secondary node to primary, and mount the /dev/drbd1, you will find the file created on the primary node is on the secondary node already.
8 Note on the first time DRBD start, it will spend some time to sync the whole disk partition.