DRBD快速安装及部署(2)

###配置资源文件redisk.res
# vi /usr/local/drbd/etc/drbd.d/redisk.res             
resource redisk {
  on orasrv1.xlk.com {
    device    /dev/drbd0;
    disk      /dev/sdb1;
    address  192.168.21.10:7789;
    meta-disk internal;
  }
  on orasrv2.xlk.com {
    device    /dev/drbd0;
    disk      /dev/sdb1;
    address  192.168.21.13:7789;
    meta-disk internal;
  }
}

###也可以通过copy方式直接将配置文件copy到节点2,则无需单独配置2个配置文件,如下:
# scp /usr/local/drbd/etc/drbd.d/* 192.168.21.13:/usr/local/drbd/etc/drbd.d/
# scp /usr/local/drbd/etc/drbd.conf 192.168.21.13:/usr/local/drbd/etc/
6、创建device metadata(两节点执行)
# drbdadm create-md redisk
Writing meta data...
initializing activity log
NOT initialized bitmap
New drbd meta data block successfully created.

[root@orasrv1 drbd.d]# drbdadm up redisk
[root@orasrv1 drbd.d]# /etc/init.d/drbd status
drbd driver loaded OK; device status:
version: 8.3.15 (api:88/proto:86-97)
GIT-hash: 0ce4d235fc02b5c53c1c52c53433d11a694eab8c build by root@orasrv1.xlk.com, 2015-10-31 09:16:05
m:res    cs            ro                ds                    p  mounted  fstype
0:redisk  WFConnection  Secondary/Unknown  Inconsistent/DUnknown  C1
5、设置Primary节点(主节点)
以下操作仅在节点1(orasrv1)执行
# drbdadm primary --force redisk
0: State change failed: (-2) Need access to UpToDate data
Command 'drbdsetup 0 primary' terminated with exit code 17
# drbdadm -- --overwrite-data-of-peer primary redisk
# mkfs.ext3 /dev/drbd0
# mkdir /data
# mount /dev/drbd0 /data
# df -h |grep data
/dev/drbd0      2.0G  36M  1.9G  2% /data

###在第二个节点上创建/data目录
# mkdir /data
###查看drbd状态信息:
#cat /proc/drbd

四、DRBD数据镜像功能测试
###首先在主节点完成如下操作
# cp -R /usr/local/drbd /data
# ls /data/drbd
etc  lib  sbin  share  var
# du -sh /data/drbd
324K    /data/drbd

# umount /data
# drbdadm secondary redisk
# cat /proc/drbd
version: 8.3.15 (api:88/proto:86-97)
GIT-hash: 0ce4d235fc02b5c53c1c52c53433d11a694eab8c build by root@orasrv1.xlk.com, 2015-10-31 10:58:13
 0: cs:Connected ro:Secondary/Secondary ds:UpToDate/UpToDate C r-----
    ns:1044700 nr:0 dw:33780 dr:1045517 al:3 bm:64 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0

###在备用节点完成如下操作 
# drbdadm primary redisk
# cat /proc/drbd
version: 8.3.15 (api:88/proto:86-97)
GIT-hash: 0ce4d235fc02b5c53c1c52c53433d11a694eab8c build by root@orasrv2.xlk.com, 2015-10-31 10:59:26
 0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r-----
    ns:0 nr:1044700 dw:1044700 dr:672 al:0 bm:64 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0
# mount /dev/drbd0 /data
# du -sh /data/drbd    ###两节点数据目录及大小完全一致
324K    /data/drbd

Linux 高可用(HA)集群之DRBD详解

DRBD中文应用指南 PDF

CentOS 6.3下DRBD安装配置笔记

基于DRBD+Corosync实现高可用MySQL

CentOS 6.4下DRBD 安装配置

DRBD 的详细介绍请点这里
DRBD 的下载地址请点这里

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/16f0266633065fd401f26849602c04ff.html