Two node HA cluster using ProxMox 2.1 and DRBD with manual fencing mechanism (only for lab!)

Recently I started experimenting with ProxMox which is a new virtualization platform based on KVM.Actually it is has a nice Web Interface where you can utilize most of the tasks quickly but the real power of course is in the console.

Here I will show how I managed to build a two node HA cluster using just two servers without an external storage.Instead of that I used the local hard disks on each server (must be the same size on each node) to emulate a HA storage using DRBD.

Warning! This a test lab solution.Do not try to utilize as a production system (at least without fencing)! You have been warned!

First of all you have to follow these Wikis to get yourself comfortable with proxmox.After reading and practicing with them you can copy/paste my configuration and adjust it for your needs.

Wiki 1: Building HA Cluster with ProxMox                                                                           Wiki 2: Two-Node High Availability Cluster with ProxMox                                                   Wiki 3: DRBD and ProxMox                                                                                                         Wiki 4: Fencing (the most important part! without fencing serious data corruption can occur!)

 

Now that you have read all these Wikis and you are comfortable with ProxMox let’s proceed…                                                                                                                              As I said before I have 2 Servers in this scenario.I have named first server proxmox1 and the second one proxmox2 with ip address 192.168.1.8 and 192.168.1.7 respectively.Below are the contents of /etc/hosts file on proxmox1 machine:

root@proxmox1:~# cat /etc/hosts
127.0.0.1 localhost.localdomain localhost
192.168.1.8 proxmox1.domain.local proxmox1 pvelocalhost

 

..and /etc/hosts file on proxmox2:

root@proxmox2:~# cat /etc/hosts
127.0.0.1 localhost.localdomain localhost
192.168.1.7 proxmox2.domain.local proxmox2 pvelocalhost

 

Also check /etc/hostname on both nodes:

root@proxmox1:~# cat /etc/hostname
proxmox1

root@proxmox2:~# cat /etc/hostname
proxmox2

 

Ok, Now lets see our /etc/pve/cluster.conf files on both nodes.Remember each time you want to change something in this file you must first copy it as a new file using cp /etc/pve/cluster.conf /etc/pve/cluster.conf.new and edit that file increasing cluster config_version value each time.I assume that you have already setup a working HA cluster setup following ProxMox Wikis:

<?xml version=”1.0″?>
<cluster config_version=”1″ name=”cluster1″>
<cman expected_votes=”1″ keyfile=”/var/lib/pve-cluster/corosync.authkey” two_node=”1″/>
<fencedevices>
<fencedevice agent=”fence_manual” name=”human”/>
</fencedevices>
<clusternodes>
<clusternode name=”proxmox1″ nodeid=”1″ votes=”1″>
<fence>
<method name=”single”>
<device name=”human” nodename=”proxmox1″/>
</method>
</fence>
</clusternode>
<clusternode name=”proxmox2″ nodeid=”2″ votes=”1″>
<fence>
<method name=”single”>
<device name=”human” nodename=”proxmox2″/>
</method>
</fence>
</clusternode>
</clusternodes>
<rm>
<pvevm autostart=”0″ vmid=”100″/>

</rm>
</cluster>

Ok, As  you may noticed in this configuration I have setup manual fencing device due to lack of having a real fence device like APC PDU in my environment.What this means is that in case of a node failure I must manually fence the failed device to avoid data corruption in my cluster.Again I have to warn you that this setup is just for lab and for a production environment!Serious data corruption can occur using this setup!

Now make the following change on /etc/default/redhat-cluster-pve

nano /etc/default/redhat-cluster-pve
# this file is sourced by the following init scripts:
# /etc/init.d/cpglockd
# /etc/init.d/cman
# /etc/init.d/rgmanager

FENCE_JOIN=”yes”

Let’s proceed to our storage setup.Below is the /etc/drbd.d/r0 resource config file for DRBD:

resource r0 {
protocol C;
startup {
wfc-timeout 15; # non-zero wfc-timeout can be dangerous (http://forum.proxmox.com/threads/3465-Is-it-safe-to-use-wfc$
degr-wfc-timeout 60;
become-primary-on both;
}
net {
cram-hmac-alg sha1;
shared-secret “password_here”;
allow-two-primaries;
after-sb-0pri discard-zero-changes;
after-sb-1pri discard-secondary;
after-sb-2pri disconnect;
}
syncer {
rate 20M;
}
on proxmox1 {
device /dev/drbd0;
disk /dev/sdb1;
address 172.16.35.1:7788;
meta-disk internal;
}
on proxmox2 {
device /dev/drbd0;
disk /dev/sdb1;
address 172.16.35.2:7788;
meta-disk internal;
}
}

 

You must copy this config on both nodes.Now let’s see /etc/network/interfaces on both nodes:

root@proxmox1:~# cat /etc/network/interfaces
# network interface settings
auto lo
iface lo inet loopback

iface eth0 inet manual

iface eth1 inet manual

auto eth2
iface eth2 inet static
address 172.16.35.1
netmask 255.255.255.0

auto vmbr0
iface vmbr0 inet static
address 192.168.1.8
netmask 255.255.255.0
gateway 192.168.1.3
bridge_ports eth0
bridge_stp off
bridge_fd 0

auto vmbr1
iface vmbr1 inet static
address 172.21.3.8
netmask 255.255.255.0
bridge_ports eth1
bridge_stp off
bridge_fd 0

root@proxmox2:~# cat /etc/network/interfaces
# network interface settings
auto lo
iface lo inet loopback

iface eth0 inet manual

iface eth1 inet manual

auto eth2
iface eth2 inet static
address 172.16.35.2
netmask 255.255.255.0

auto vmbr0
iface vmbr0 inet static
address 192.168.1.7
netmask 255.255.255.0
gateway 192.168.1.3
bridge_ports eth0
bridge_stp off
bridge_fd 0

auto vmbr1
iface vmbr1 inet static
address 172.21.3.7
netmask 255.255.255.0
bridge_ports eth1
bridge_stp off
bridge_fd 0

I have three network interfaces configured. The 172.16.35.0/24 subnet is dedicated for DRBD replication.

Now change this line on /etc/lvm/lvm.conf :

# By default we accept every block device:
filter = [ “r|/dev/sdb1|”, “r|/dev/disk/|”, “r|/dev/block/|”, “a/.*/” ]

..where /dev/sdb1 is the block device that I use in drbd.

At this point you should be ready to go and test on-line migration of HA vm between two nodes.Also you can test a failure scenario where one of the two hosts fails by unplugging it’s power cord or network cables.Because of the manual fencing mechanism that I use here you must invoke fence_ack_manual command on the working node and respond: absolutely so the vm on the failed node migrates on the working one.Below you can see some screenshots of my setup in action!Feel free to experiment…ProxMox is a great free product that can do what the others do but with a little effort 🙂

 

 

 

How to remove and re-install Unity on Ubuntu

This is what i used when i had a problem with it.


Use this to Remove/Uninstall Compiz Unity:

sudo apt-get remove compizconfig-settings-manager 
sudo apt-get remove compiz-fusion-plugins-extra 
sudo apt-get remove compiz-plugins-extra 
sudo apt-get purge compiz* 

Then to Re-install Compiz Unity use:

sudo apt-get install unity-2d 
sudo apt-get install ubuntu-desktop 
sudo apt-get install ubuntu-desktop-2d 
sudo apt-get install compizconfig-settings-manager 
sudo apt-get install xserver-xgl 
sudo apt-get install emerald 
sudo apt-get install compiz-fusion-plugins-extra 
sudo apt-get install git compiz-plugins-extra 
sudo apt-get install compiz-plugins-extra 
sudo apt-get install unity 

Source: Link

How to configure networking of Ubuntu Server 10.04 in Hyper-V

Enabling modules

Firstly it must ensure that the Hyper-V modules are loaded at startup. To do this, edit the file /etc/initramfs-tools/modules and add the following four lines:

hv_vmbus
hv_storvsc
hv_blkvsc
hv_netvsc

Then, update the initramfs image:

$ sudo update-initramfs – u

Finally, configure the network by changing the /etc/network/interfaces file to configure the network interface named eth0. Indeed, a synthetic NIC would be named seth n instead of eth n for “legacy” network adapter.

For example for a DHCP configuration, add the following to /etc/network/interfaces:

Auto eth0
iface eth0 inet dhcp

or, for a static IP address:

Auto eth0
iface eth0 inet static
address ip_address
netmask mask

Source: Link

How to install x2go server (remote desktop) on Ubuntu 12.04LTS

Add the X2Go repository on Launchpad to APT

Use the following commands to add the ppa:x2go/stable as a package source to your local system. Before doing so, you might like to learn about apt-get, sudo and ppas

Alternatively you can also use the Ubuntu software center.

$ sudo add-apt-repository ppa:x2go/stable $ sudo apt-get update

You might have to install add-apt-repository first using:

$ sudo apt-get install python-software-properties

The X2Go related packages should now be listed calling:

$ apt-cache search x2go

Congratulations, you are now able to access the X2Go packages. You may continue by installing x2goserver, x2goclient or pyhoca-gui or any other of the available packages.

General minimal guide/steps to install x2goserver on Ubuntu

After adding the x2go PPA (see above) on your remote Ubuntu “desktop” server there are a few general steps to follow to install the x2goserver for use.

Start a ssh terminal session with the remote Ubuntu server.

If you have not copied ssh keys (see x2go wiki section called Advanced x2go Setups) in order to use automatic login by user to the remote server without having to enter their password and instead you plan to require remote users to enter both their UserID and Password on their x2go client then you will need to edit/modify /etc/ssh/sshd_config and change the entry for ChallengeResponseAUthentication from NO to YES then restart ssh (sudo /etc/init.d/ssh restart).

The next step is to install the primary x2goserver packages.

$ sudo apt-get install x2goserver x2goserver-xsession

Download the client for Windows,Linux & Mac
Source: Link