Chinaunix首页 | 论坛 | 博客
  • 博客访问: 287185
  • 博文数量: 29
  • 博客积分: 2200
  • 博客等级: 大尉
  • 技术积分: 305
  • 用 户 组: 普通用户
  • 注册时间: 2006-05-29 00:05
文章分类

全部博文(29)

文章存档

2018年(1)

2014年(2)

2012年(4)

2011年(5)

2009年(5)

2008年(1)

2007年(3)

2006年(8)

我的朋友

分类: LINUX

2011-04-14 11:04:41

因为我们目前只是用到这么简单的功能,所以没有复杂的东西,以后用到了再补充.
 
1.yum install drbd
 

2.rpm -Uvh kmod-drbd  如果启动时(步骤5)显示StartingDRBDresources: Can not load the drbd module则安装这个
 

3.vi /etc/drbd.conf
###########################################
#
# please have a a look at the example configuration file in
# /usr/share/doc/drbd82/drbd.conf
#
global { usage-count yes; }
common {
    #
    syncer { rate 10M; }
    }
    resource r0 {
    #
    protocol C;
    net { cram-hmac-alg sha1;
      shared-secret "FooFunFactory";}
    disk { on-io-error detach; }
    #
    on postgres-db1.edgesoft.cn {
    device /dev/drbd0;
    disk /dev/sdb1;
    address 10.4.5.71:7788;
    meta-disk internal;
    }
    on postgres-db2.edgesoft.cn {
    device /dev/drbd0;
    disk /dev/sdb1;
    address 10.4.5.81:7788;
    meta-disk internal;
    }
    }
###########################################
 
 
4.drbdadm create-md r0
     ---------------------------------------------------------------------------
     如果提示如下错误,可以执行这个命令解决:dd if=/dev/zero bs=1M count=1 of=/dev/sdb1:
     v08 Magic number not found
     md_offset 10733953024
     al_offset 10733920256
     bm_offset 10733592576
    
     Found ext3 filesystem which uses 10482380 kB
     current configuration leaves usable 10482024 kB
    
     Device size would be truncated, which
     would corrupt data and result in
     'access beyond end of device' errors.
     You need to either
        * use external meta data (recommended)
        * shrink that filesystem first
        * zero out the device (destroy the filesystem)
     Operation refused.
    
     Command 'drbdmeta /dev/drbd0 v08 /dev/sdb2 internal create-md' terminated with exit code 40
     drbdadm aborting
     ---------------------------------------------------------------------------
 
 
5./etc/init.d/drbd start
--------------------------------------------------------------------
此时状态 cat /proc/drbd
version: 8.0.0 (api:86/proto:86)SVN Revision: 2713 build by , 2008-06-27 14:07:14
 1: cs:Connected st:Secondary/Secondary ds:Inconsistent/Inconsistent C r---   
 ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0       
 resync: used:0/31 hits:0 misses:0 starving:0 dirty:0 changed:0       
 act_log: used:0/257 hits:0 misses:0 starving:0 dirty:0 changed:0
--------------------------------------------------------------------
 

6.drbdsetup /dev/drbd0 primary -o
--------------------------------------------------------------------
此时状态: 同步中...
[root@postgres-db1 ~]# cat /proc/drbd
version: 8.2.6 (api:88/proto:86-88)
GIT-hash: 3e69822d3bb4920a8c1bfdf7d647169eba7d2eb4 build by , 2008-10-03 11:42:32
 0: cs:SyncSource st:Primary/Secondary ds:UpToDate/Inconsistent C r---
    ns:85600 nr:0 dw:0 dr:85600 al:0 bm:5 lo:0 pe:0 ua:0 ap:0 oos:10396424
        [>....................] sync'ed:  0.9% (10152/10236)M
        finish: 0:16:07 speed: 10,700 (10,700) K/sec
--------------------------------------------------------------------
 
7.mkfs.ext3 /dev/drbd0
 
8.mount -t ext3 /dev/drbd0 /sy_drbd
可以正常使用了,在/sy_drbd里创建\删除\修改的内容都会同步到secondary中
=====================================================================================================
DRBD的主备机切换
>>primary:
umount /dev/drbd0
drbdadm secondary r0
>>secondary:
drbdadm primary r0
mount -t ext3 /dev/drbd0 /sy_drbd/
 

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
想看看secondary上是否真正同步了,可以使用如下方法
[root@postgres-db2 ~]# /etc/init.d/drbd stop
Stopping all DRBD resources.
[root@postgres-db2 ~]# mount -t ext3 /dev/sdb1 /sy_drbd/
[root@postgres-db2 ~]# cd /sy_drbd/
[root@postgres-db2 sy_drbd]# ls
kmod-drbd82-8.2.6-2.i686.rpm  lost+found
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
阅读(3895) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~