用DRBD和OCFS2实现数据同步和共享(6)

[root@centos6-ocfs2-1 ~]# mounted.ocfs2 -d
--------------------------------------------------------------------------------
Device      Stack  Cluster  F  UUID                              Label
/dev/sdb    o2cb               7C477028C9F942C1BC5CAFF2B24A7A5A
/dev/sdb1   o2cb               0AFD511ACB744A5BB7EC21BAF3323883  ocfs2
/dev/drbd0  o2cb               0AFD511ACB744A5BB7EC21BAF3323883  ocfs2
--------------------------------------------------------------------------------


[root@centos6-ocfs2-2]# /etc/init.d/drbd force-reload;# Update driver;
[root@centos6-ocfs2-2]# /etc/init.d/drbd restart; # Or restart;
[root@centos6-ocfs2-2 drbd.d]# mounted.ocfs2 -d
--------------------------------------------------------------------------------
Device      Stack  Cluster  F  UUID                              Label
/dev/sdb    o2cb               99BF2CA35AD1498CA2D8EA9315F0605D
/dev/sdb1   o2cb               0AFD511ACB744A5BB7EC21BAF3323883  ocfs2
/dev/drbd0  o2cb               0AFD511ACB744A5BB7EC21BAF3323883  ocfs2
--------------------------------------------------------------------------------

────────────────────────────────────────────────────────────────────────────────
Switch the DRBD in Active-Active mode
────────────────────────────────────────────────────────────────────────────────
# vi /etc/drbd.d/ocfs2.res;
--------------------------------------------------------------------------------
# DRBD resource for OCFS2 storage
resource ocfs2 {
  protocol      C;
  startup {
    become-primary-on both;
  }
  net {
    allow-two-primaries;
    after-sb-0pri discard-zero-changes;
    after-sb-1pri discard-secondary;
    after-sb-2pri disconnect;
  }
  on centos6-ocfs2-1 {
    device    /dev/drbd0;
    disk      /dev/sdb1;
    address   192.168.56.201:7789;
    meta-disk internal;
  }
  on centos6-ocfs2-2 {
    device    /dev/drbd0;
    disk      /dev/sdb1;
    address   192.168.56.202:7789;
    meta-disk internal;
  }
}
--------------------------------------------------------------------------------
Note: Add startup{} and net{} on both nodes, not need to changing other settings.


参数解释:

allow-two-primaries
  - Generally, DRBD has a primary and a secondary node. In this case, we will allow
    both nodes to have the filesystem mounted at the same time. Do this only with
    a clustered filesystem. If you do this with a non-clustered filesystem like
    ext2/ext3/ext4 or reiserfs, you will have data corruption. Seriously!

after-sb-0pri discard-zero-changes
  - DRBD detected a split-brain scenario, but none of the nodes think they're a primary.
    DRBD will take the newest modifications and apply them to the node that didn't have any changes.

after-sb-1pri discard-secondary
  - DRBD detected a split-brain scenario, but one node is the primary and the other is the secondary.
    In this case, DRBD will decide that the secondary node is the victim and it will sync data
    from the primary to the secondary automatically.

after-sb-2pri disconnect
  - DRBD detected a split-brain scenario, but it can't figure out which node has the right data.
    It tries to protect the consistency of both nodes by disconnecting the DRBD volume entirely.
    You'll have to tell DRBD which node has the valid data in order to reconnect the volume.
    Use extreme caution if you find yourself in this scenario.


[root@centos6-ocfs2-1]# /etc/init.d/drbd restart;

(Waiting to the restart untill it successfully,and then restart node2's DRBD)

[root@centos6-ocfs2-2]# /etc/init.d/drbd restart;

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

转载注明出处:http://www.heiqu.com/629ebe60a358b37b031eb21782d36a2c.html