We currently migrate to MediaWiki from our old installation, but not all content has been migrated yet. Take a look at the Wiki Team page for instructions how to help or browse through our new wiki at wiki.linux-vserver.org to find the information already migrated.

The idea is simple:

Install a vserver on a DRBD resource and let it failover to the other node of a cluster.

This configuration uses vserver, DRBD and heartbeat. This page will not describe, how these packages are installed and configured. Only the important topics are mentioned.

Steps of installation:

In detail

Prepare the disk space:

You will need some block device like /dev/hdaX, or a better choice is to use LVM.

lvcreate -L3000 -nlvvs03 vg0

A recommended method is, to have DRBD metadata on an extra block device for each DRBD device.

Prepare space for it:

lvcreate -L132 -nlvvs03md vg0

Create an entry in /etc/drbd.conf using your favorite editor:

resource vs03 {
  protocol C;
  incon-degr-cmd "echo '!DRBD! pri on incon-degr' | wall ; sleep 60 ; halt -f";

  startup {
    wfc-timeout  100;
    degr-wfc-timeout 120;    # 2 minutes.
  }

  disk {
    on-io-error   pass_on;
  }

  net {
    # sndbuf-size 512k;
    # timeout       60;    #  6 seconds  (unit = 0.1 seconds)
    # connect-int   10;    # 10 seconds  (unit = 1 second)
    # ping-int      10;    # 10 seconds  (unit = 1 second)
    # max-buffers     2048;
    # max-epoch-size  2048;
    # ko-count 4;
    # on-disconnect reconnect;
  }

  syncer {
    rate 10M;
    group 1;
    al-extents 257;
  }

  on cel600 {
    device     /dev/drbd1;
    disk       /dev/vg0/lvvs03;
    address    192.168.0.22:7789;
    meta-disk  /dev/vg0/lvvs03md[0];
  }

  on xp2400 {
    device    /dev/drbd1;
    disk      /dev/vg0/lvvs03;
    address   192.168.0.21:7789;
    meta-disk /dev/vg0/lvvs03md[0];
  }
}

Start DRBD

/etc/init.d/drbd start

The DRBD resource is in an undefined state. It needs to be forced to be 'primary' on the current node.

drbdsetup /dev/drbd1 primary --do-what-I-say

Obviously a filesystem is needed on top of DRBD:

mke2fs -j /dev/drbd1

Also we need a mount point somewhere:

mkdir /mnt/vs03

As heartbeat is intended to manage the vserver, using the heartbeat script for mounting is a first test:

/etc/ha.d/resource.d/Filesystem /dev/drbd1 /mnt/vs03 ext3 start

There are many methods how to install a vserver. Here 'debootstrap' is used. The important option is '--rootdir' to force the installation to the DRBD device.

vserver -v vs03 build --force --rootdir /mnt/vs03 \
-m debootstrap --hostname vs03.nack.at \
--netdev eth0 --interface 192.168.0.3/24 --context 3 -- \
-d sarge -m http://ftp.at.debian.org/debian/

We could start the vserver now. But first we try to make the configuration more pretty.

cd /mnt/vs03/vs03/etc/rc0.d
rm K20makedev K25hwclock.sh S30urandom S31umountnfs.sh  S35networking S36ifupdown S40umountfs S90halt K89klogd
cd ../rc6.d
rm K20makedev K25hwclock.sh S30urandom S31umountnfs.sh  S35networking S36ifupdown S40umountfs S90reboot K89klogd
cd ../rcS.d
rm S05keymap.sh S48console-screen.sh S50hwclock.sh S40networking  S45mountnfs.sh S10checkroot.sh S02mountvirtfs
rm S30procps.sh S35mountall.sh S36mountvirtfs S39ifupdown S30checkfs.sh S18ifupdown-clean S18hwclockfirst.sh
cd ../rc2.d
rm S20makedev S11klogd

If we want to have virtual IPs managed by heartbeat, there can be conflicts, if we do not 'name' the alias of the vserver IP.

echo vs03 > /etc/vservers/vs03/interfaces/0/name

sshd should only listen to the IPs of the host context:

xp2400:/# cat /etc/ssh/sshd_config | grep ListenAddress
ListenAddress 192.168.0.21:22
ListenAddress 192.168.0.20:22

After these checks it's time to start the vserver:

xp2400:/# vserver vs03 start

Check if the interface is nicely named and shown with ifconfig:

xp2400:/#  ip addr show
[...]
2: eth0: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 00:30:bd:6b:d6:8f brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.21/24 brd 192.168.0.255 scope global eth0
    inet 192.168.0.3/24 brd 192.168.0.255 scope global secondary eth0:vs03
    inet6 fe80::230:bdff:fe6b:d68f/64 scope link
       valid_lft forever preferred_lft forever

xp2400:/# ifconfig
eth0      Link encap:Ethernet  [...]

eth1      [...]

eth0:vs03 Link encap:Ethernet  HWaddr 00:30:BD:6B:D6:8F
          inet addr:192.168.0.3  Bcast:192.168.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:177 Base address:0xd000

Enter the vserver:

xp2400:/# vserver vs03 enter

In the vserver we check the base configuration and install some packages.

vs03:/# base-config
vs03:/# apt-get update
vs03:/# apt-get install locales
vs03:/# apt-get install less
vs03:/# nano /etc/resolv.conf
vs03:/# ping www.linux-vserver.org

We want to install at least one service, sshd.

vs03:/# apt-get install ssh
vs03:/# nano /etc/ssh/sshd_config
vs03:/# cat /etc/ssh/sshd_config | grep ListenAddress
ListenAddress 192.168.0.3:22
vs03:/# /etc/init.d/ssh restart
Restarting OpenBSD Secure Shell server: sshd.
vs03:/# passwd
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
vs03:/# exit
logout

Test the ssh login:

xp2400:/# ssh root@192.168.0.3
The authenticity of host '192.168.0.3 (192.168.0.3)' can't be established.
RSA key fingerprint is e2:19:d1:8d:7f:ac:0a:ce:12:f5:06:b7:ae:41:96:59.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.0.3' (RSA) to the list of known hosts.
Password: <secret>
vs03:~#

The configuration on one node is ready.

To be continued ...