Wednesday, March 31, 2010

CrashPlan - A perfect home backup solution

Crashplan is a perfect backup solution for home use. It is free, but the online backup service (optional) is not expensive at all. It supports most of your OS platforms (Linux, Mac, Windows, open solaris) and is really easy to use. I use it for all my machines at home, making cross-backups locally and also for backing up my precious data to Crashplan central.

Even thou Crashplan is a GUI  based application there is no problem using it on a X-less (Headless) Linux server. you install it in the console and then connect to it from your Mac or windows machine using a ssh tunnel. Ssh tunneling basically forwards a connection from a local port on your computer to a port on a remote machine and is as easy to setup as making a ssh to your server.
Here is an example:
ssh -L 4200:localhost:4243 username@your_host
This connects to the remote server as a regular SSH connection, but as long as you are logged in it will also keep a "port forwarding" from your localmachine on port 4200 to the remote host´s 4243 port.

Then all you have to do is to locate CrashPlans ui.properties file and add this line:
servicePort=4200
When you start Crashplan locally on your computer, it will connect to localhost:4200. Your SSH connection will then forward the connection (undetected by Crashplan client) to the remote host´s crashplan service.

Just remember to comment out the servicePort line after you are done configuring the host.

Saturday, March 27, 2010

XenServer Install: Adding a local ISO storage

This is my last post for now, regarding XenServer installation. After this blog you should be able to start installing your first VM.

First of all I want to warn you that there is limited storage space on the xenserver it self, so I recommend setting up a samba server where you put all the iso images and then map the samba share as a ISO Repos.

Login to your Xenserver with ssh and create a iso folder
mkdir -p /var/opt/xen/iso_import
then I copy my net install version of debian over (this is done from the machine you download the image to. It will copy the file over ssh)
scp root@:/var/opt/xen/iso_import
Then I create the ISO store like this
xe sr-create name-label="myLocal ISO" type=iso device-config:location=/var/opt/xen/iso_import/ device-config:legacy_mode=true content-type=iso
Then verify that the ISO is added:

xe vdi-list

Expected output should be something like this:

uuid ( RO)                : 71ee9aae-906e-4002-bbdd-8802132e71b0
          name-label ( RW):

    name-description ( RW):
             sr-uuid ( RO): 020842d0-5df0-55a6-906f-2e21e17adc39
        virtual-size ( RO): 137832448
            sharable ( RO): false
           read-only ( RO): true

Thats it. Then you can go ahead and create your first VM machine.

XenServer Install: Adding local storage repositories

If you remember one of my tips during the XenServer install, it was to not select all your local storage as repotitory during the installation. The reason for this is that I want to add the different disks I have as different storage repositories in order to control which of my RAIDs are used for system disks and data disks. I fount this brilliant blog http://www.archy.net/2009/05/21/adding-local-storage-to-xenserver-55/ that describes the process, but I am going to repeat Stephane´s actions here.

First we need to detect the drives we want to add. This we do by running a "fdisk -l". In my case I see several disks, but the ones I am interested in is my datadisk and a non-Raid backupdisk:
Disk /dev/sdb: 3000.4 GB, 3000409915392 bytes
255 heads, 63 sectors/track, 364779 cylinders
Units = cylinders of 16065 * 512 = 8225280 byte

Disk /dev/sdc: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
From this listing I can see that it is /dev/sdb and /dev/sdc that I want to add.

I then run pvcreate on these disks:
pvcreate /dev/sdb
pvcreate /dev/sdc
Then you need to find the disks id string in the /dev/disk/by_id folder. Listing my folder reviles my disks
scsi-27f1dad4b7c900104 -> ../../sdb
scsi-SATA_SAMSUNG_HD252HJS17HJ90S401838 -> ../../sdc
As you can see scsi-27f1dad4b7c900104 is id for sdb and scsi-SATA_SAMSUNG_HD252HJS17HJ90S401838 is id for sdc. The reason we do this is that incase we change the order of our disks or controllers (for instance adding a local SATA disk may add a new sdb and push the other disks down to sdc and sdd).
Ok, next we do some XenServer magic to add the storage repositories.

xe sr-create type=lvm content-type=user device-config:device=/dev/disk/by-id/scsi-27f1dad4b7c900104 name-label="DATA SR"

xe sr-create type=lvm content-type=user device-config:device=/dev/disk/by-id/scsi-SATA_SAMSUNG_HD252HJS17HJ90S401838 name-label="BACKUP SR"

That is it.

In my next blog, I will add a local ISO repos to hold the most used ISOs I use to install servers.

Friday, March 26, 2010

XenServer install: Monitor the RAID controller

When you install hardware RAID controllers, you do not have a monitoring feature like mdadm that can monitor your controller. monitoring is crucial to make sure your server is up and running. No need to have RAID if you do not know when you loose a drive. The Promise EX8350 was a bit challenging to get good monitoring, but after alot of googling I found a solution. You need the CLI tool from Promise. this I downloaded here: http://www.promise.com/upload/Support/Utility/2.5.0-25_64bitCLI.rar
I downloaded the file and copied the rpmfile over to the XenServer using scp.
then installed it:
rpm -i i2cli-2.5.0-25.i386.rpm

This installs a CLI command that you can use to view, modify your controller.

I reconfigured the ssmpt.conf file to a working config for me (this is the outgoing mailserver on the XenServer, so it is able to send email out).
Then I created a small Bash script.
NOTE! This is not optimized at ALL. Just meshed it together and saw that it worked :-) Please fork the gist and update it if you improve it. Use it at own risk. I recommend testing everything before you start adding data and servers on the system.

You can see the file here: http://gist.github.com/344939

I added the file to crontab: (crontab -e)
*/30 * * * * /usr/sbin/check_raid.sh

Now you will receive emails every 30 minutes for as long as the RAID is degraded (one of the RAIDS)

In the next blog I will show you how I added the other RAIDS as Server Repositories, because you can not add these from the admin tool, it must be done from console.

XenServer Install: The network speed

After installing I was confused if the network was actually 1GBit or not. My switch says 1Gbit, eth-tool says gigabit (from console: ethtool eth0), mii-tool says 100Mbit and the funniest of all; the NIC Speed LED shows orange and claims 100Mbit. To be sure I had to do some testing.

So I installed netcat on the XenServer to test. found the netcat software here: http://netcat.sourceforge.net/download.php. Downloaded the i386.rpm version (did not find a 64-bit version). PS! you can use wget from the xenserver console, so you do not have to scp the file over after downloading.
Install the rpm:
rpm -i

XenServer protects itself with firewall on all non-used ports, so to test netcat, you have to open the firewall. I added these two lines (since I am not sure if it is udp or tcp):

/etc/sysconfig/iptables:
-A RH-Firewall-1-INPUT -p udp -m udp --dport 31233 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 31233 -j ACCEPT

I added the lines, right after this line: -A RH-Firewall-1-INPUT -p tcp -m tcp --dport 631 -j ACCEPT
you need to do a :
service iptables restart
to reload the firewall settings

then I could fire up a netcat like this:
nc -v -v -l -n -p 31233 >/dev/null
Then from my laptop (with cabled network ofcourse):
time yes|nc -v -v -n 192.168.0.8 31233 >/dev/null
(be sure to change the IP to your servers IP address)
Let it run for 10 secs and press CTRL+c
Then on the XenServer you can see how much data was transferred. If it ran for 10seconds, it must be well over 100MByte. (Mine was 420MByte)

After this is done you can close down the firewall changes, if you like.
Conclusion for me was that the speed is >100Mbit, so the ethernet card is in 1Gbit as I want it to be.

XenServer Install: The Install

The actual installation of Xen is very simple. There are however a few tricks I can recommend, that I had to do.
Be sure to firmware upgrade all of your hardware prior to installing. This is always recommended.

  1. Here is guide to installing: http://www.howtoforge.com/virtualization-with-xenserver-5.5.0
  2. If your CPU does not support VT (Virtualization Technology), you can still continue installation, but you can not install Windows guest OSes and your linux installs must be done with xen-patched linux kernels.
  3. When using the IDE CDROM drive I get "A base installation repository was not found at that location." The tutorial says you can then do a "modprobe ide-generic" from the console, but that did not help me. (Do not know why). So I connected a USB CDROM drive instead and installed from that. That works great.
  4. Use static IP on your management port, unless you have MAC reservation activated in your DHCP server
  5. find local NTP servers for time sync. Virtual machines drift quite alot in time, so it is important to have a master clock that is correct
  6. I got a question during install if I wanted all disks enabled as Storage Repository. DO NOT MARK ALL DRIVES. If you do it will merge all your disks together to one LVM, which is not good if you want to have control where the virtual disks are stored.
  7. Install the Linux pack CD as well. This is mandatory in my mind if you want to install Linux quests
  8. After install enable remote SSH, so you can work from your regular computer when doing all post config.

In my next blog entry, I will write about all the post-config and checking I had to do.
This includes:
- Network Speed troubleshooting
- Setup monitoring of the EX8350 RAID controller (so I receive emails when the RAID fails)

XenServer Install: My hardware

XenServer has a rather limited installer. This means setting up Software Raids and stuff is not so simple, but doable. I have found several posts on the net describing how to install XenServer on Software RAID.


First attempt: Failure to communicate

My first attempt ended up with hardware issues. I have a Promise EX8350 PCI Express card and wanted to use this in my current Gigabyte GA-EP45-UD3LR motherboard. This did not end well. The mainboard does not want to boot with the RAID controller in the PCIx slot (yes, I changed the BIOS setting to start PCI graphics as primary). I tried several BIOS version of the mainboard, bt no luck.


The hunt for hardware

I started looking around for a new mainboard and found a perfect card. ASUS P5Q Premium. this card is built for virtualization :-). It has 4Gigabit ethernet ports, 4 PCIExpress ports, and much more.. I have read comments about this card and people claim that you do not need 4NICs. Well if you want to use it for virtualization, 4 ports can be very handy. If you for instance have a iSCSI NAS. this NAS can then run on its own gigabit NICs, which is preferred to maintain speed. As for my setup I am only going to use 2 for now. One for internal servers and one for DMZ servers.


The HW configuration

Here is the configuration I ended up with. (this all seems to work in XenServer 5.5)

* ASUS P5Q Premium motherboard
* 8GB DDR2 PC6400 RAM
* Promise EX8350 RAID controller
* Gainward GeForce8400GS for console :-)
* 4 250GB Maxtor 6L250S0 in a RAID10
* 4 1TB SAMSUNG HD103UJ in a RAID5

the next step is the installation and configuration of XenServer...