免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2332 | 回复: 0
打印 上一主题 下一主题

磁盘镜像--DRBD [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-04-13 11:55 |只看该作者 |倒序浏览


DRBD® refers to block devices designed as a building block to form high availability (HA) clusters. This is done by mirroring a whole block device via an assigned network. DRBD can be understood as network based raid-1.
In the illustration above, the two orange boxes represent two servers that form an HA cluster. The boxes contain the usual components of a Linux™ kernel: file system, buffer cache, disk scheduler, disk drivers, TCP/IP stack and network interface card (NIC) driver. The black arrows illustrate the flow of data between these components.
The orange arrows show the flow of data, as DRBD mirrors the data of a high availably service from the active node of the HA cluster to the standby node of the HA cluster.
一、安装
    1、从
http://www.drbd.org/
下载最新的源码包drbd-8.0.13.tar.gz
    2、tar xvf drbd-8.0.13.tar.gz
    3、cd drbd-8.0.13
    4、make
    5、make install
    6、modprobe drbd

二、配置
    1、为本地主机和远程主机准备DRBD使用的分区,大小必须相同
    2、/etc/drbd.conf
        global {usage-count yes;}
        common {syncer {rate 100M;}}
        resource r0 {
            protocol C;            //使用协议C.表示收到远程主机的写入确认后,则认为写入完成.
            net {
                cram-hmac-alg sha1;    //设置主备机之间通信使用的信息算法
                shared-secret "FooFunFactory";
            }

            on gfs-1 {
                device /dev/drbd1;
                disk /dev/sdb4;
                address 192.168.12.161:7788;  //设置DRBD的监听端口,用于与另一台主机通信
                meta-disk internal;
            }

            on gfs-2 {
                device /dev/drbd2;
                disk /dev/sda4;
                address 192.168.12.145:7788;
                meta-disk internal;
            }
        }
           
    3、分别在gfs-1、gfs-2上创建供DRBD记录信息的数据块
        drbdadm create-md r0
    4、分别在gfs-1、gfs-2上启动DRBD服务
        /etc/init.d/drbd start
    5、查看DRBD状态
        cat /proc/drbd
        显示了drbd当前的状态,gfs-1、gfs-2都是secondary机,磁盘状态ds为不一致,这是因为DRBD无法识别哪台机器为主机,哪台机器为备机
    6、以gfs-2为例设置主机,gfs-1为备机
        drbdsetup /dev/drbd2 primary -o
    7、查看DRBD状态
        cat /proc/drbd
        显示主备机状态st分别是"主/备",主机磁盘状态是"实时",备机状态是"不一致",还可以看到数据同步的进度,待数据同步完成,磁盘状态ds都显示实时UpToDate
三、测试
    主机的DRBD设备可以被挂载,而备机的DRBD则不行
    1、在gfs-2上挂载DRBD设备
        mkdir -p /mnt/drbd2
        mkfs.ext3 /dev/drbd2
        mount /dev/drbd2 /mnt/drbd2
        cd /mnt/drbd2
        touch a.c
    2、在gfs-1上查看
        /etc/init.d/drbd stop
        mkdir -p /mnt/drbd1
        mount /dev/sdb4 /mnt/drbd1
        ls /mnt/drbd1
        可以看到在gfs-2上创建的文件a.c




   


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/93196/showart_1899195.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP