Quite often it usefull to circumvent the initial resync. The resync that gets triggered with the ‘drbdadm – –do-what-I-say primary’ command. In case you will create a filesystem on the device anyway, it might be handy to do the initial resync over night.
DRBD-0.7 / DRBD plus 0.7
Using the (rather old) write_gc.pl and read_gc.pl
Make sure that the devices are connected
Instead of calling ‘drbdadm – –do-what-I-say primary’ you stop it on both nodes again ‘/etc/init.d/drbd stop’
-
‘chmod +x write_gc.pl read_gc.pl’
Call ‘read_gc.pl’ to see the content of the generation counters in the meta-data
Call ‘write_gc.pl [resname] 1’ to mark the local data as consistent on both nodes
Start drbd on both nodes ‘/etc/init.d/drbd start’. The nodes will connect, both disks will be in consistent state, allowing you to set the role of one node to primary without doing an initial resync.
Using the drbdmeta program
Get an executable of drbdmeta, which is packaged with drbd-8.0.x
Make sure that the devices are connected
Instead of calling ‘drbdadm – –do-what-I-say primary’ you stop it on both nodes again ‘/etc/init.d/drbd stop’
Call ‘drbdmeta /dev/drbd0 v07 /dev/ubdc 0 show-gi’ to see the content of the generation counters in the meta-data. Of course you have to replace /dev/drbd0 with the device you mean. /dev/ubdc is the real block device where the metadata is on, and the 0 is the meta-data index. In case you use internal meta-data put there the word “internal” instead of the index.
Call ‘drbdmeta /dev/drbd0 v07 /dev/ubdc 0 set-gi 1’ to set the consistent bit on both nodes. (Of course you have to replace...)
Start drbd on both nodes ‘/etc/init.d/drbd start’. The nodes will connect, both disks will be in consistent state, allowing you to set the role of one node to primary without doing an initial resync.
DRBD-8.x / DRBD plus 8.x
On both nodes:
modprobe drbd
drbdadm create-md <res>
drbdadm -- 6::::1 set-gi <res>
drbdadm up <res>
These commands create the meta data, set the current UUID and highlight the relevant data as valid. Please note that although no initial resynchronisation is being triggered, all bits are set in the bitmap during establishment of the connection. In order to avoid a full resynchronisation during the next establishment of the connection, the following steps are necessary on both nodes:
drbdadm down <res>
drbdadm dump-md <res> > /tmp/md
sed -i -r -e 's/0xF{16}/0x0000000000000000/g' /tmp/md
This leads to a dump of the meta data and with the sed command, the bits of the bitmap are reset. Restoring the meta data has to be done directly with drbdmeta. In order to do so, you should request how drbdmeta needs to be invoked in order to create the dump:
drbdadm -d dump-md r0
Just replace the command dump-md by restore-md when calling drbdmeta and add /tmp/md to the line, e.g.
drbdmeta /dev/drbd0 v08 /dev/ubdb internal restore-md /tmp/md
As a last step, the device is re-activated on both nodes:
drbdadm up <res>