I have a great working version of DRBD across two Debian Stretch servers which I created by following this awesome guide: https://www.howtoforge.com/setting-up-network-raid1-with-drbd-on-debian-squeeze-p2/
But after each reboot I have to redo a number of things to get it into a working state again.
Here is what I see when it's working, before reboot:
root@server1:~# cat /proc/drbd
version: 8.4.7 (api:1/proto:86-101)
srcversion: AC50E9301653907249B740E
0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r-----
ns:8 nr:0 dw:4 dr:1209 al:1 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0
On server 2:
root@server2:~# cat /proc/drbd
version: 8.4.7 (api:1/proto:86-101)
srcversion: AC50E9301653907249B740E
0: cs:Connected ro:Secondary/Primary ds:UpToDate/UpToDate C r-----
ns:0 nr:8 dw:8 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0
On server 1:
root@server1:~# mount
...
/dev/drbd0 on /var/www type ext3 (rw,relatime,data=ordered)
And here is what I see after reboot. All is working but mounting, service start, and primary/secondary configurations is lost. I've tried to add drbd
to the start by doing this:
update-rc.d drbd defaults
on both servers this doesn't seem to work. DRBD simply doesn't start but manually doing /etc/init.d/drdb start
works fine on both servers.
Also I'm unsure if I can just add the DRBD volumes to fstab
because surely it won't work if the DRBD service isn't even started? I've read about using _netdev
in fstab
but various combinations of fstab
entries didn't work out.
Finally I also have to set the primary and secondary status of DRBD every time I restart and then remount the volume manually.
So this is how I am getting it working after reboot:
On server 1:
root@server1:/etc# /etc/init.d/drbd status
● drbd.service - LSB: Control DRBD resources.
Loaded: loaded (/etc/init.d/drbd; generated; vendor preset: enabled)
Active: inactive (dead)
Docs: man:systemd-sysv-generator(8)
root@server1:/etc# /etc/init.d/drbd start
[ ok ] Starting drbd (via systemctl): drbd.service.
root@jmtest1:/etc# cat /proc/drbd
version: 8.4.7 (api:1/proto:86-101)
srcversion: AC50E9301653907249B740E
0: cs:Connected ro:Secondary/Secondary ds:UpToDate/UpToDate 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:0
root@server1:/etc# drbdadm primary r0
root@server1:/etc# cat /proc/drbd
version: 8.4.7 (api:1/proto:86-101)
srcversion: AC50E9301653907249B740E
0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate 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:0
On server 2:
root@server2:~# /etc/init.d/drbd status
● drbd.service - LSB: Control DRBD resources.
Loaded: loaded (/etc/init.d/drbd; generated; vendor preset: enabled)
Active: inactive (dead)
Docs: man:systemd-sysv-generator(8)
root@server2:~# /etc/init.d/drbd start
[ ok ] Starting drbd (via systemctl): drbd.service.
root@server2:~# cat /proc/drbd
version: 8.4.7 (api:1/proto:86-101)
srcversion: AC50E9301653907249B740E
0: cs:Connected ro:Secondary/Secondary ds:UpToDate/UpToDate 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:0
root@server2:~# drbdadm secondary r0
root@server2:~# cat /proc/drbd
version: 8.4.7 (api:1/proto:86-101)
srcversion: AC50E9301653907249B740E
0: cs:Connected ro:Secondary/Primary ds:UpToDate/UpToDate 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:0
Some fstab
entries that I tried:
/dev/drbd0 /var/www ext3 _netdev 0 2
UUID=042cc2e395b2b32 /var/www ext3 none,noauto 0 0
Not sure if you're supposed to use the UUID or just /dev/drbd0
I have these questions as to why it's not starting:
- What FSTAB entries are supposed to be there?
- Why does
update-rc.d drbd defaults
not work? - Why do I have to reset primary and secondary on both servers after each restart?