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!

23 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. Thank you very much It works now.

    ReplyDelete
  5. lifesaver; thank you :)

    ReplyDelete
  6. Thank you, it worked for me.

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

    ReplyDelete
  8. Thanks it worked !

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

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

    ReplyDelete
  11. 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
  12. Disable SElinux and restart. It worked for me

    ReplyDelete
  13. muito obrigado man

    ReplyDelete
  14. I have installed drdb on opensuse15.2 the service is working fine but
    I have faced some issue so please check and give me your valuable feedback

    Error:
    -------
    1. cat /proc/drbd
    version: 9.0.22-1 (api:2/proto:86-116)
    GIT-hash: fe2b59836bdf1c7c81ccbaad8ef8016d9c3ba582 reproducible build, 2020-11-03 12:00:00
    Transports (api:16): tcp (9.0.22-1)

    2.drbdadm primary testdata1 --force
    testdata1: State change failed: (-2) Need access to UpToDate data
    Command 'drbdsetup primary testdata1 --force' terminated with exit code 17

    ReplyDelete