Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2096608
  • 博文数量: 229
  • 博客积分: 7217
  • 博客等级: 上校
  • 技术积分: 3224
  • 用 户 组: 普通用户
  • 注册时间: 2009-02-19 17:23
个人简介

个人主页https://xugaoxiang.com,微信公众号: Dev_Club 或者搜索 程序员Club

文章分类

全部博文(229)

文章存档

2017年(1)

2016年(20)

2015年(23)

2013年(1)

2012年(23)

2011年(68)

2010年(62)

2009年(31)

分类: 服务器与存储

2009-04-13 11:55:50

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、从下载最新的源码包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
 
 
 
 
  
阅读(1820) | 评论(0) | 转发(0) |
0

上一篇:soft-RAID realization

下一篇:lustre文件系统

给主人留下些什么吧!~~