DRBD安装配置文档

系统:DVD最小化安装centos6.4系统
(centos5 yum 安装 需要开启extras源)
主机:
Ⅰ.HOSTNAME:vm01-centos ip:192.168.0.55
Ⅱ.HOSTNAME:vm02-centos ip:192.168.0.82
drbd版本:drbd-8.4.3
原理

             +------------+
             | 文件系统 |
             +------------+
                      |
                     V
            +----------------+
            |   块设备层    |
            | (/dev/drbd0) |
            +----------------+
                |               |
                |               |
               V              V
+---------------+ +-------------------+
|  本地硬盘    |  |远程主机硬盘  |
|(/dev/xvdb5)|  |  (/dev/xvdb5)  |
+---------------+ +-------------------+

step.1.安装
依赖环境

yum install glib2-devel libtool-ltdl-devel net-snmp-devel bzip2-devel \
ncurses-devel openssl-devel libtool libxml2-devel gettext bison flex zlib-devel \
mailx which libxslt-devel docbook-dtds docbook-style-xsl PyXML shadow-utils opensp \autoconf automake make cmake libuuid-devel libxslt libxslt-devel libgcrypt-devel pkgconfig \
libgpg-error-devel sgml-common opensp openjade xml-common docbook-dtds flex rpm-build \
kernel-devel gcc xfsprogs xfsdump -y
mkdir -p /root/rpmbuild/SOURCES

关闭iptables,selinux

service iptables stop 
chkconfig iptables off
setenforce 0 sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config

编译安装

tar zxvf drbd-8.4.3.tar.gzcd drbd-8.4.3
./configure --with-utils  --with-udev --with-xen --with-heartbeat --with-pacemaker --with-rgmanager --with-bashcompletionmake rpm 
make km-rpmcd /root/rpmbuild/RPMS/x86_64 
rpm -ivh drbd-*.rpm

step.2.配置

vi /etc/drbd.d/global_common.conf
global {
        usage-count yes;}common {
        handlers {
                pri-on-incon-degr "/usr/lib/drbd/notify-pri-on-incon-degr.sh; /usr/lib/drbd/notify-emergency-reboot.sh; echo b > /proc/sysrq-trigger ; reboot -f";
                pri-lost-after-sb "/usr/lib/drbd/notify-pri-lost-after-sb.sh; /usr/lib/drbd/notify-emergency-reboot.sh; echo b > /proc/sysrq-trigger ; reboot -f";
                local-io-error "/usr/lib/drbd/notify-io-error.sh; /usr/lib/drbd/notify-emergency-shutdown.sh; echo o > /proc/sysrq-trigger ; halt -f";        } 
        startup {
                wfc-timeout 30;
                degr-wfc-timeout 30;
                outdated-wfc-timeout 30;                # wait-after-sb
        } 
        options {
                # cpu-mask on-no-data-accessible
        } 
        disk {
                on-io-error detach;
                fencing resource-and-stonith;
                resync-rate 15M;        } 
        net {
                protocol C;
                cram-hmac-alg sha1;
                shared-secret "YOEKEY-_-";        }}
vi /etc/drbd.d/vm00-centos.res
resource vm00-centos {device /dev/drbd0;
disk /dev/vg_drbd01/lv_drbd01;
meta-disk internal;
on vm01-centos {address 192.168.0.55:9876;}on vm02-centos {address 192.168.0.82:9876;}}

主从服务器创建相同大小的lvm

fdisk -l /dev/xvdb
    Device Boot      Start         End      Blocks   Id  System/dev/xvdb1               1         652     5237158+   5  Extended/dev/xvdb5               1         652     5237127   8e  Linux LVM
pvcreate /dev/xvdb5
vgcreate vg_drbd01 /dev/xvdb5
vgchange -a y vg_drbd01
vgdisplay vg_drbd01 |grep "Total PE"
  Total PE              1278lvcreate -l 1278 -n lv_drbd01 vg_drbd01
modprobe drbd
drbdadm create-md vm00-centos
drbdadm up vm00-centos

两个服务器执行上面相同操作
========================
选择主服务器

drbdadm primary vm00-centos#提升为主服务器成功后drbd-overview  0:vm00-centos/0  Connected Primary/Secondary UpToDate/UpToDate C r----- /DATA xfs 5.0G 33M 5.0G 1%mkfs.xfs /dev/drbd0mkdir /DATAmount /dev/drbd0 /DATA/df -hFilesystem            Size  Used Avail Use% Mounted on/dev/mapper/VolGroup00-LogVol00
                      8.7G  1.2G  7.1G  15% /tmpfs                 497M     0  497M   0% /dev/shm/dev/xvda1            194M   27M  158M  15% /boot/dev/drbd0            5.0G   33M  5.0G   1% /DATA

切换主从服务器
1.主服务器降级

umount /DATA/drbdadm secondary vm00-centos

2.从服务器升级

drbdadm primary vm00-centos 
mkdir /DATAmount /dev/drbd0 /DATA/


你可能感兴趣的:(drbd)