cd /tmp
wget http://oss.linbit.com/drbd/8.4/drbd-8.4.1.tar.gz
tar xzf drbd-8.4.1.tar.gz
cd drbd-8.4.1
./configure --prefix=/usr/local/drbd --with-km
make KDIR=/usr/src/kernels/2.6.18-274.18.1.el5-i686/
make install
mkdir -p /usr/local/drbd/var/run/drbd
cp /usr/local/drbd/etc/rc.d/init.d/drbd /etc/rc.d/init.d
chkconfig --add drbd
chkconfig drbd on
安装drbd模块:
cd drbd
make clean
make KDIR=/usr/src/kernels/2.6.18-274.18.1.el5-i686/
cp drbd.ko /lib/modules/`uname -r`/kernel/lib/
depmod
#fdisk /dev/hdb //准备为 hdb 建立分区
The number of cylinders for this disk is set to 20805.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): n //键入 n 表示要建立分区
Command action
e extended
p primary partition (1-4)
p //键入 p 表示建立主要分区
Partition number (1-4): 1 //键入 1 为此主要分区代号
First cylinder (1-20805, default 1): //开始磁柱值,按下 enter 即可
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-20805, default 20805): //结束磁柱值,按下 enter 即可
Using default value 20805
Command (m for help): w //键入 w 表示确定执行刚才设定
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@node1 yum.repos.d]# partprobe //使刚才的 partition table 变更生效
建立分区完成后使用指令 fdisk -l 确定 partition talbe 状态
#fdisk -l
Disk /dev/hda: 21.4 GB, 21474754560 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 13 104391 83 Linux
/dev/hda2 14 2610 20860402+ 8e Linux LVM
Disk /dev/hdb: 10.7 GB, 10737377280 bytes
16 heads, 63 sectors/track, 20805 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Device Boot Start End Blocks Id System
/dev/hdb1 1 20805 10485688+ 83 Linux
建立分区完成后请建立 /db 目录。 (Node1 及 Node2 都必须建立)
#mkdir /db
建立Drbd配置文件
主要定义两块global和resource。
vi /usr/local/drbd/etc/drbd.conf
写入:
include "drbd.d/global_common.conf";
include "drbd.d/*.res";
vi /usr/local/drbd/etc/drbd.d/global_common.conf
写入
global {
usage-count yes;
}
common {
net {
protocol C;
}
}
vi /usr/local/drbd/etc/drbd.d/r0.res
写入
resource r0 {
on node1 {
device /dev/drbd1;
disk /dev/hdb1;
address 192.168.1.101:7789;
meta-disk internal;
}
on node2 {
device /dev/drbd1;
disk /dev/hdb1;
address 192.168.1.103:7789;
meta-disk internal;
}