# Manual recovery of drbd two primary mode failures

**URL:** <https://linux-tips.com/t/manual-recovery-of-drbd-two-primary-mode-failures/238>\
**Category:** Administration\
**Created:** [December 12, 2014, 10:09pm UTC](https://linux-tips.com/t/manual-recovery-of-drbd-two-primary-mode-failures/238 "2014-12-12T22:09:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![demirten](https://linux-tips.com/user_avatar/linux-tips.com/demirten/32/64_2.png) [@demirten](https://linux-tips.com/u/demirten)\
**Post date:** [December 12, 2014, 10:09pm UTC](https://linux-tips.com/t/manual-recovery-of-drbd-two-primary-mode-failures/238/1 "2014-12-12T22:09:58Z")

</div>

You can build an active-active Linux cluster only using 2 servers with drbd. This setup requires drbd configured in _allow-two-primaries_ mode, logical volume manager with clustered locking and a clustered filesystem like _gfs2_.

But especially if you are not using a hardware fencing device, bad things can happen.

For example, you have two identical server named A and B, you lost network connection on A for a reasonable time, you just reboot both A and B and both nodes started on _Primary/Unknown_ mode. When drbd runs with this mode, your drbd setup unaware of changes made on other node. You have to solve this problem and make drbd setup sync again.

First of all you have to decide which node has most recent modifications, node A or node B?

If you know that node B has most recent changes and want to fully synchronize node A from node B, you have to follow this guideline.

To start working on node A, we have to disconnect node A from drbd resource pool (assume that resource name is _data\_res_):

**Important!** Run following commands on node A.

```
$ sudo drbdadm disconnect data_res

```

If you got an error like _Invalid configuration request_ you already disconnected from the resource pool, so ignore this error.

After disconnect, A node still _Primary/Unknown_ state, you have to change state to Secondary. To do this run following command:

```
$ sudo drbdadm secondary data_res

```

If you’re using a clustered filesystem over lvm, you will get an error something like that _device already opened_ or _State change failed: (-12) Device is held open by someone_. You can solve this problem with unmounting cluster filesystem and de-activating volume group which runs on drbd device. You can get volume group names with `vgdisplay` command. If you have a volume group named _vg-data_, it can be de-activated with:

```
$ sudo vgchange -an vg-data

```

After that we can try to make node A secondary again.

In the last step on the node A, we will connect to drbd resource pool again:

```
$ sudo drbdadm connect --discard-my-data data_res

```

**Important!** Run following commands on node B.

Sometimes our node B system can be in Standalone mode at this step. To start drbd synchronization, you have to run connect command on node B too like below (it is not required other than the Standalone mode):

```
$ sudo drbdadm connect data_res

```

That’s all, syncronization will start automatically. You can monitor the process through `/proc/drbd`. Node A and Node B will be _cs:Connected ro:Primary/Primary ds:UpToDate/UpToDate_ mode again after synchronization completed.

If Node A still seen as Secondary, you have to change it’s state to primary (run following command on Node A):

```
$ sudo drbdadm primary data_res

```

Now you can confirm that both of the Node A and Node B seems Primary/Primary:

```
$ sudo drbd-overview 
0:data_res/0 Connected Primary/Primary UpToDate/UpToDate C r----- lvm-pv
```
