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


# /etc/init.d/drbd status
--------------------------------------------------------------------------------
drbd driver loaded OK; device status:
version: 8.3.11 (api:88/proto:86-96)
srcversion: DA5A13F16DE6553FC7CE9B2
m:res    cs         ro               ds                 p  mounted  fstype
0:ocfs2  Connected  Primary/Primary  UpToDate/UpToDate  C
--------------------------------------------------------------------------------
Note: now both nodes have the same status Primary/Primary.


# vi /etc/fstab; # configurate the bootup mount point;
--------------------------------------------------------------------------------
/dev/drbd0 /mnt/ocfs ocfs2  _netdev,datavolume,nointr0 0
--------------------------------------------------------------------------------

# /etc/init.d/ocfs2 start
# /etc/init.d/o2cb status
--------------------------------------------------------------------------------
Driver for "configfs": Loaded
Filesystem "configfs": Mounted
Stack glue driver: Loaded
Stack plugin "o2cb": Loaded
Driver for "ocfs2_dlmfs": Loaded
Filesystem "ocfs2_dlmfs": Mounted
Checking O2CB cluster "ocfs2": Online
  Heartbeat dead threshold: 31
  Network idle timeout: 30000
  Network keepalive delay: 2000
  Network reconnect delay: 2000
  Heartbeat mode: Local
Checking O2CB heartbeat: Active
--------------------------------------------------------------------------------
Note: both nodes's heartbeat active now.


# /usr/sbin/drbd-overview; #(a perl script come form drbd8x-utils);
--------------------------------------------------------------------------------
0:ocfs2 Connected Primary/Primary UpToDate/UpToDate C r----- /mnt/ocfs ocfs2 1020M 82M 939M 8%
--------------------------------------------------------------------------------
Note: drbd-overview is just a simple perl script to read /proc/drbd;


Testing to change or add files on both nodes, and you will see the changing had
been synchronized to other node immediately. Successfully and completed now !

################################################################################
Startup Setup(If reboot linux can not mount the OCFS2 file system automatically)
################################################################################
Note: make sure the ocfs2 script run after drbd script when linux system stratup.

# vi /etc/init.d/ocfs2;
--------------------------------------------------------------------------------
# chkconfig: 2345 25 18
--------------------------------------------------------------------------------

# cat /etc/init.d/o2cb
--------------------------------------------------------------------------------
# chkconfig: 2345 24 19
--------------------------------------------------------------------------------

As you can see, the start and stop priorities of o2cb and ocfs2 are 24 and 25 .


# vi /etc/init.d/drbd
--------------------------------------------------------------------------------
# chkconfig: - 70 08
# Should-Start:   sshd multipathd
# Should-Stop:    sshd multipathd
CHANGE TO:
# chkconfig: - 23 08
# Should-Start:
# Should-Stop:  
--------------------------------------------------------------------------------
# chkconfig --del drbd;
# chkconfig --add drbd;
# /bin/ls -l -d /etc/rc*.d/*drbd*;
# chkconfig drbd off;
# chkconfig drbd on;
# /bin/ls -l -d /etc/rc*.d/*drbd*;

# vi /etc/init.d/httpd;
--------------------------------------------------------------------------------
# chkconfig: - 85 15
CHANGE TO:
# chkconfig: - 85 05
--------------------------------------------------------------------------------
# chkconfig --del httpd;
# chkconfig --add httpd;
# /bin/ls -l -d /etc/rc*.d/*httpd*;
# chkconfig httpd off;
# chkconfig httpd on;
# /bin/ls -l -d /etc/rc*.d/*httpd*;

################################################################################
Debug: 当使用Active-Active模式时出现两边都是StandAlone的情况之处理
################################################################################
# drbd-overview; #Both two nodes change to StandAlone
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
0:ocfs2 StandAlone Primary/Unknown UpToDate/DUnknown r----- /mnt/ocfs ocfs2 1020M 82M 939M 8%
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

(1) first, check both file system and decide with node to give up;

(2) stop the mount point on this node:
    # /etc/init.d/ocfs2 stop;

(3) disconnect the drbd device:
    # drbdadm disconnect all;

(4) change to secondary status:
    # drbdadm secondary all;
    # drbdadm -- --discard-my-data connect all;
    # drbd-overview;

(5) on the other node, if its connection state is also StandAlone, you would enter:
    # drbdadm connect all;
    # drbd-overview;

(6) check the re-synchronization status
    # /etc/init.d/drbd status;

(7) switch back to primary status
    #  drbdadm primary all;
    # drbd-overview;

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

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