http://www.drbd.org/docs/about/
http://oss.linbit.com/drbd/
安装drbd
# wget http://oss.linbit.com/drbd/8.4/drbd-8.4.3.tar.gz
# tar zxvf drbd-8.4.3.tar.gz
# cd drbd-8.4.3
# ./configure --prefix=/usr/local/drbd --with-km
# make KDIR=/usr/src/kernels/2.6.32-279.el6.x86_64/
yum -y install kernel-devel kernel-headers flex
注意:安装kernel-devel一定要和你uname -r 看到的内核版本一致,建议kernel-devel用本地源安装,不要用网络源安装
[[email protected] soft]# tar zxf drbd-8.4.3.tar.gz
[[email protected] soft]# cd drbd-8.4.3
[[email protected] drbd-8.4.3]# ./configure --prefix=/usr/local/drbd --with-km
注意:--with-km是启用内核模块
[[email protected] ~]# make KDIR=/usr/src/kernels/2.6.32-358.el6.i686
注意KDIR的路径 (这个内核源码路径需要根据自己的系统修改)
[[email protected] drbd-8.4.3]# make install
[[email protected] ~]# mkdir -p /usr/local/drbd/var/run/drbd
[[email protected] ~]# cp /usr/local/drbd/etc/rc.d/init.d/drbd /etc/rc.d/init.d/
[[email protected] ~]# chkconfig --add drbd
[[email protected] ~]# chkconfig drbd on
安装drbd模块
回到刚刚解压drbd的目录,然后
[[email protected] drbd-8.4.3]# cd drbd
[[email protected] drbd]# make clean
[[email protected]]# make KDIR=/usr/src/kernels/2.6.32-358.el6.i686
[[email protected] drbd]# cp drbd.ko /lib/modules/`uname -r`/kernel/lib/
[[email protected] drbd]# modprobe drbd
查看模块是否加载成功
[[email protected] drbd]# lsmod | grep drbd
drbd 292307 0
先看看系统的内核版本
# uname -r (目前的版本)
2.6.32-279.el6.x86_64
下面以安装drbd模块为例进行说明
正确安装drbd模块后,使用modprobe进行加载
# modprobe drbd
FATAL: Module drbd not found.
出现如上错误
原因:这是因为系统默认的内核并不支持此模块,所以需要更新内核
更新内核的方法:
可以用 yum install kernel* 方式来更新。
如果你要节约点时间的话可以只更新一下的几个包:
kernel-devel
kernel
kernel-headers
更新后,记得要重新启动操作系统!!!
# depmod
说明:在编译并准备好一个Linux内核加载模块后,modprobe前必须先执行命令depmod,此命令会生成新的modules.dep。
[[email protected] ~]# depmod
[[email protected] ~]# modprobe drbd
[[email protected] ~]# lsmod|grep drbd
drbd 325786 0
libcrc32c 1246 1 drbd
编辑配文
[[email protected] ~]# vi /etc/drbd.conf
resource r0{
protocol C;
startup { wfc-timeout 0; degr-wfc-timeout 120;}
disk { on-io-error detach;}
net{
timeout 60;
connect-int 10;
ping-int 10;
max-buffers 2048;
max-epoch-size 2048;
}
syncer { rate 30M;}
on bd1{
device /dev/drbd0;
disk /dev/sdb1;
address 172.16.2.1:7788;
meta-disk internal;
}
on bd2{
device /dev/drbd0;
disk /dev/sdb1;
address 172.16.2.2:7788;
meta-disk internal;
}
}
创建分区
# fdisk /dev/sdb
----------------
n-p-1-1-"+1G"-w
----------------
# mkdir /data
创建DRBD设备并激活ro资源:(Primary,Secondary)
# mknod /dev/drbd0 b 147 0
# drbdadm create-md r0
等待片刻,显示success表示drbd块创建成功
--== Thank you for participating in the global usage survey ==--
The server‘s response is:
you are the 19411th user to install this version
no resources defined!
因为配文错误应该是下面的位置,而不是/etc/drbd.conf
[[email protected] ~]# vi /usr/local/drbd/etc/drbd.conf
[[email protected] ~]# drbdadm create-md r0
Writing meta data...
initializing activity log
NOT initializing bitmap
New drbd meta data block successfully created.
success
linux服务之drbd