DRBD : configuration master/master + cluster filesystem OCFS2

Boris HUISGEN October 17, 2012

administration système linux ha drbd ocfs2

Réplication DRBD

root@node1#:~# apt-get install drbd8-utils
root@node1#:~# cat /etc/drbd.d/global_common.conf

global {
    usage-count no;
}

common {
    protocol C;

    handlers {
        pri-on-incon-degr "/usr/lib/drbd/notify-pri-on-incon-degr.sh; /usr/lib/drbd/notify-emergency-reboot.sh; echo b > /proc/sysrq-trigger ; reboot -f";
        pri-lost-after-sb "/usr/lib/drbd/notify-pri-lost-after-sb.sh; /usr/lib/drbd/notify-emergency-reboot.sh; echo b > /proc/sysrq-trigger ; reboot -f";
        local-io-error "/usr/lib/drbd/notify-io-error.sh; /usr/lib/drbd/notify-emergency-shutdown.sh; echo o > /proc/sysrq-trigger ; halt -f";
    }

    startup {
        wfc-timeout 0;
        degr-wfc-timeout 120;
        become-primary-on both;
    }

    disk {
        on-io-error detach;
    }

    net {
        cram-hmac-alg "sha1";
        shared-secret "blablablaaaaaaaaaaa";
        max-buffers 2048;
        ko-count 4;
        allow-two-primaries;
        after-sb-0pri discard-zero-changes;
        after-sb-1pri discard-secondary;
        after-sb-2pri disconnect;
    }

    syncer {
        rate 40M;
        verify-alg "crc32c";
    }
}

root@node1:~# cat /etc/drbd.d/r0.res

resource r0 {
        on drbd1 {
                device /dev/drbd0;
                disk /dev/vg/data;
                address 192.168.1.211:7788;
                meta-disk internal;
        }

        on drbd2 {
                device /dev/drbd0;
                disk /dev/vg/data;
                address 192.168.1.212:7788;
                meta-disk internal;
        }
}

root@node1:~# drbdadm create-md r0
root@node1:~# /etc/init.d/drbd start
root@node1:~# drbdadm syncer r0
root@node1:~# drbdadm connect r0
root@node2:~# apt-get install drbd8-utils
root@node2:~# scp root@node1:/etc/drbd.d/* /etc/drbd.d/
root@node2:~# drbdadm create-md r0
root@node2:~# /etc/init.d/drbd start
root@node2:~# drbdadm syncer r0
root@node2:~# drbdadm connect r0
root@node1:~# drbdadm -- --overwrite-data-of-peer primary r0
root@node1:~# drbdadm primary r0
root@node1:~# cat /proc/drbd

version: 8.3.7 (api:88/proto:86-91)
srcversion: EE47D8BF18AC166BE219757
0: cs:Connected ro:Primary/Primary ds:UpToDate/UpToDate C r----
ns:4300921 nr:3429 dw:110206 dr:8403592 al:39 bm:260 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:0

root@node2:~# drbdadm primary r0
root@node2:~# cat /proc/drbd

version: 8.3.7 (api:88/proto:86-91)
srcversion: EE47D8BF18AC166BE219757
0: cs:Connected ro:Primary/Primary ds:UpToDate/UpToDate C r----
ns:756 nr:825 dw:1581 dr:3131 al:2 bm:1 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:0

Mise en place du filesystem OCFS2

root@node1:~# apt-get install ocfs2-tools
root@node1:~# cat /etc/ocfs2/cluster.conf

cluster:
    name = ocfs2
    node_count = 2

node:
    number = 1
    name = node1
    ip_address = 192.168.1.211
    ip_port = 7777
    number = 1
    cluster = ocfs2

node:
    number = 2
    name = node2
    ip_address = 192.168.1.212
    ip_port = 7777
    cluster = ocfs2

root@node1:~# /etc/init.d/ocfs2 start
root@node1:~# /etc/init.d/o2cb start
root@node1:~# mkfs.ocfs2 /dev/drbd0
root@node1:~# mount.ocfs2 /dev/drbd0 /mnt/
root@node2:~# apt-get install ocfs2-tools
root@node2:~# scp root@node1:/etc/ocfs2/* /etc/ocfs2/
root@node2:~# /etc/init.d/ocfs2 start
root@node2:~# /etc/init.d/o2cb start
root@node2:~# mount.ocfs2 /dev/drbd0 /mnt/

See also

MySQL : script de sauvegarde par snapshot LVM
Read more
Postfix : gérer les extensions d’adresses avec Dovecot en LDA
Read more
Debian : regénérer la configuration GRUB 2
Read more