安装drbd过程:(实验借鉴:http://www.it165.net/os/html/201309/6317.html)
yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 gcc gcc-c++ autoconf
hostname web1/web2 不然在后续找不到资源定义 关闭防火墙以及注意selinux
注意:安装kernel-devel一定要和你
uname
-r 看到的内核版本一致,建议kernel-devel用本地源安装,不要用网络源安装
# 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-358.el6.i686/ 编译到内核里面
make install
cp /usr/local/drbd/etc/rc.d/init.d/drbd /etc/init.d/
cd /usr/local/drbd/var;mkdir run;cd run;mkdir drbd
然后回到解压的目录,执行清理:
cd /lvs/drbd-8.4.3/drbd;make clean
make KDIR=/usr/src/kernels/2.6.32-358.el6.i686/;make && make install
cp drbd.ko /lib/modules/2.6.32-358.el6.i686/kernel/lib/
modprobe drbd
加载到内核lsmod | grep drbd
mknod /dev/drbd0 b 147 0
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
cd /usr/local/drbd/etc/drbd.d
vi drbd.res
resource drbd {
on web1 {
device /dev/drbd0;
disk /dev/sdb1;
address 192.168.1.22:7789;
meta-disk internal;
}
on web2 {
device /dev/drbd0;
disk /dev/sdb1;
address 192.168.1.23:7789;
meta-disk internal;
}
}drbdadmin create-md drbd
/etc/init.d/drbd start
1 需要注意的是,先要drbdadmn create-md drbd==》service drbd start (如果还是不一致,请检查配配置文件磁盘名是否正确)
主:
drbdadm -- --overwrite-data-of-peer primary all 设置主
drbdadm role drbd
mkfs.ext4 /dev/drbd0
partprobe /dev/drbd0
mount /dev/drbd0 /挂载
2 主切换到备,然后主需要再恢复使用,主和备都需要start查找一下
3如果是yum安装drbd一定要将/usr/share/doc/drbd83-8.3.15下的drbd.conf覆盖到/etc/下面的drbd.conf。否则初始化会包没有定义资源错误
4还需要注意的是:两台机器先分区-然后drbd设置好主借点后,在格式化/dev/drbd资源,然后再挂载