yum install kernel* -y ##升级内核
reboot
wget http://oss.linbit.com/drbd/8.4/drbd-8.4.1.tar.gz ##下载drbd8.4.1
tar xvzf drbd-8.4.1.tar.gz
cd drbd-8.4.1
./configure --with-km --with-heartbeat ##--with-xen --with-pacemaker --with-rgmanager
make KDIR=/usr/src/kernels/2.6.18-274.12.1.el5xen-x86_64/ ##内核目录要与uname -a 输出的对应
make install KDIR=/usr/src/kernels/2.6.18-274.12.1.el5xen-x86_64/
modprobe drbd ##将drbd模块加载到内核
lsmod |grep drbd ##查看一下是否加载成功
drbdadm --version ##看一下版本输出
cp scripts/drbd /etc/init.d/ ##将drbd启动脚本复制到/etc下
/etc/init.d/drbd ##测试一下脚本的可用性
##drbd的配置文件在/usr/local/etc/drbd.d/下
cp scripts/global_common.conf /usr/local/etc/drbd.d/ ##复制全局配置文件/usr/local/etc/drbd.d/下还应有resource配置文件
cp scripts/drbd.conf* /usr/local/etc/ ##复制drbd-8.4.0/scripts/下的实例配置文件
chkconfig --level 2345 drbd on ##加入系统服务
默认安装后的配置文件在/usr/local/etc/
vim /usr/local/etc/drbd.conf
- include "drbd.d/global_common.conf";
- include "drbd.d/*.res";
vim /usr/local/etc/drbd.d/global_common.conf
- resource r0 {
- on server01 {
- volume 0 {
- device /dev/drbd0;
- disk /dev/xvdb5;
- flexible-meta-disk internal;
- }
- address 192.168.0.193:7788;
- }
- on server02 {
- volume 0 {
- device /dev/drbd0;
- disk /dev/xvdb5;
- flexible-meta-disk internal;
- }
- address 192.168.0.194:7788;
- }
- }
在两个节点上
dd if=/dev/zero of=/dev/xvdb5 bs=1M count=128
drbdadm create-md r0
/etc/init.d/drbd start
在主节点上
drbdsetup /dev/drbd0 primary --o
drbdadm primary r0
mkfs.xfs /dev/drbd0
mount /dev/drbd0 /drbd
drbdadm primary db