tar xf drbd-8.4.3.tar.gz cd drbd-8.4.3 ./configure --prefix=/usr/local/drbd --sysconfdir=/etc/drbd \ --datarootdir=/usr/local/share/ --with-utils --with-km make KDIR=/usr/src/kernels/`uname -r`/ make install mkdir -p /usr/local/drbd/var/run/drbd cp -a /etc/drbd/rc.d/init.d/drbd /etc/rc.d/init.d/ chkconfig --add drbd chkconfig drbd on cd drbd make clean make KDIR=/usr/src/kernels/`uname -r`/ cp drbd.ko /lib/modules/`uname -r`/kernel/lib/
[root@s1 drbd]# fdisk /dev/sdc <------------------命令在此 Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0x2e8e99bb. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command'c') and change display units to sectors (command'u').
Command (m forhelp): m <------------------命令在此 Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partitions system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only)
Command (m forhelp): n <------------------命令在此 Command action e extended p primary partition (1-4) p Partition number (1-4): 1 <------------------命令在此 First cylinder (1-39, default 1): <------------------命令在此 Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-39, default 39): <------------------命令在此 Using default value 39
[root@s1 drbd.d]# drbdadm create-md myres1 Writing meta data... initializing activity log NOT initializing bitmap New drbd meta data block successfully created. success
启动服务
s1,s2:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
[root@s1 drbd.d]# service drbd start Starting DRBD resources: [ create res: myres1 prepare disk: myres1 adjust disk: myres1 adjust net: myres1 ] outdated-wfc-timeout has to be shorter than degr-wfc-timeout outdated-wfc-timeout implicitly set to degr-wfc-timeout (120s) [root@s1 drbd.d]# service drbd status #或 drbdadm role myres1 或 cat /proc/drbd 或 drbd-overview drbd driver loaded OK; device status: version: 8.4.4 (api:1/proto:86-101) GIT-hash: 74402fecf24da8e5438171ee8c19e28627e1c98a build by root@s1, 2017-05-07 00:05:41 m:res cs ro ds p mounted fstype 0:myres1 Connected Secondary/Secondary UpToDate/UpToDate C
注:一定不能在 /myres1 当前目录操作,会报错 umount: /myres1: device is busy. (In some cases useful info about processes that use the device is found by lsof(8) or fuser(1)) 坑了我好长时间。
将从节点置主
1 2 3 4 5 6
[root@s2 drbd.d]# drbdadm primary myres1 [root@s2 drbd.d]# mount /dev/drbd0 /myres1/ [root@s2 myres1]# cd /myres1/ && ll total 12 -rw-r--r-- 1 root root 0 May 7 01:43 IamS1 drwx------ 2 root root 12288 May 7 01:39 lost+found