Monday, February 27, 2012

Error When Promoting DRBD Primary

I was having some issues today setting up DRBD on some new SANs. When I would try and promote one of the SANs to primary using this command:
sudo drbdadm -f primary r0

I would get this error:
0: State change failed: (-2) Need access to UpToDate data
Command 'drbdsetup 0 primary' terminated with exit code 17

Checking the status reveals:
cat /proc/drbd
version: 8.3.11 (api:88/proto:86-96)
srcversion: DA5A13F16DE6553FC7CE9B2
 0: cs:Connected ro: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 ep:1 wo:f oos:1953460984

The reason for this is because neither server can tell if it has the correct data, so we need to invalidate one of them, so the other one thinks it is up-to-date. This is pretty simple. On the secondary server, simple use this command (replacing r0 with your resource):
sudo drbdadm invalidate r0

That's it. You can now successfully set your primary server with:
sudo drbdadm -f primary r0

Now check your status:
cat /proc/drbd

and you should see something similar to:
version: 8.3.11 (api:88/proto:86-96)
srcversion: DA5A13F16DE6553FC7CE9B2
 0: cs:SyncSource ro:Primary/Secondary ds:UpToDate/Inconsistent C r-----
    ns:1818624 nr:0 dw:0 dr:1819288 al:0 bm:110 lo:0 pe:48 ua:0 ap:0 ep:1 wo:f oos:1951645432
        [>....................] sync'ed:  0.1% (1905900/1907676)Mfinish: 16:47:51 speed: 32,260 (30,772) K/sec

Huzzah, success!

19 comments:

  1. No works for me....still same error !!


    # drbdadm primary r0
    0: State change failed: (-2) Need access to UpToDate data
    Command 'drbdsetup primary 0' terminated with exit code 17

    ReplyDelete
  2. It worked for me at least. Thanks.

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. lifesaver; thank you :)

    ReplyDelete
  5. Thank you, it worked for me.

    ReplyDelete
  6. Option -f is unknown. Instead, use this:
    $ drbdadm --force primary r0

    ReplyDelete
  7. Thanks it worked !

    ReplyDelete
  8. drbdadm invalidate drbd0
    0: State change failed: (-11) Device is diskless, the requested operation requires a disk

    ReplyDelete
  9. I am not able to up my resource, still with the same issue

    ReplyDelete
  10. When I run drbdadm up r0, I get
    open(/dev/sdb) failed: device or resource busy
    Operation cancelled.
    command 'drbdmeta 0 v08 /dev/sdb internal apply-al' terminated with exit code 20

    ReplyDelete