Tuesday, 4 May 2010

How to convert / migrate image based vm (guest / dom-U) to LVM based vm (virtual machine)-(Guest / dom-U) using xen.

Hi all, In this article we will learn how to install virtual machine on sparse file (image file) and how to migrate / move it to LVM based storage / disk. It is recommended to use LVM based partition to install virtual machines for productions environment, as you may experience performance issues if you use images (sparse files) to install virtual machine.

How to install virtual machine on image based disk ...

I will presume that you have a server running xend on it. In my case I am using CentOS 5.4 and xend 3.0.3. After your xen dom-0 server is ready we need to install dom-u on it. First we will install dom-u using sparse (image)file. please follow steps listed below.
  1. Create sparse file using command
    #dd if=/dev/zero of=/home/xenvm01.img bs=1M count=1 seek=4096.
    I am considering that you have enough disk space in /home partition and you want to install a virtual machine under that partition. please use relevent partition as per your choice. After this command completes successfully, you will see a image file xenvm01.img
  2. Now we need to install virtual maching using this image file as disk. use
    #virt-install -p --name=xenvm01 --location=http://10.10.10.1/centos53/ --bridge=xenbr0 --ram=512 --file=/home/xenvm01.img -x "ks=http://10.10.10.1/xenvm01.ks?ip=10.10.10.11"
  3. After installation is completed, you will able to login to newly installed virtual machine.
    Configuration for this xen guest (dom-U) is stored in /etc/xen/ directory. my configuration file looks like.
      name = "xenvm01"
      uuid = "056a8eb9-c5e8-dc42-1f5a-a048d9a58f74"
      maxmem = 512
      memory = 512
      vcpus = 1
      bootloader = "/usr/bin/pygrub"
      on_poweroff = "destroy"
      on_reboot = "restart"
      on_crash = "restart"
      vfb = [ ]
      disk = [ "tap:aio:/home/xenvm01.img,xvda,w" ]
      vif = [ "mac=00:16:3e:1f:c3:a4,bridge=xenbr0" ]
  4. How to convert /migrate image based xen virtual machine (guest) to LVM based Guest

  5. To achieve this reult we need a volume group with free space not allocated to any logical volume. On my test system I've a volume group called "xenimg01" which has free space.
      [root@localhost ~]#vgdisplay
      --- Volume group ---
      VG Name xenimg01
      System ID
      Format lvm2
      Metadata Areas 1
      Metadata Sequence No 2
      VG Access read/write
      VG Status resizable
      MAX LV 0
      Cur LV 1
      Open LV 1
      Max PV 0
      Cur PV 1
      Act PV 1
      VG Size 50.00 GB
      PE Size 4.00 MB
      Total PE 12799
      Alloc PE / Size 3328 / 13.00 GB
      Free PE / Size 9471 / 37.00 GB
      VG UUID 5IZDY3-Vs4o-Zs26-p7sx-CaRk-8kdi-eX9fZC
    ... You can see from the above output that it has approximately 37 GB free. If you remember correctly , in our previous section we created an image disk of size 4 GB (4096 MB) to install guest OS. To convert that image based guest to LVM based disk we need logical volume with exactly same size .i.e 4 GB (4096 MB). lets create a logical volume now.
  6. [root@localhost ~]#lvcreate -L4096M -n lvmxen01 xenimg01.
    Logical volume "lvmxen01" created

    We don't need to format this logical volume. We will use it as raw disk to migrate / convert dom-u (guest) OS to it.
  7. Shutdown the dom-u we installed earlier.
      [root@localhost ~]#xm shutdown xenvm01
    After the xenvm01 virtual machine is donw completely you need to use command specified next to convert it to LVM based dom-U
  8. [root@localhost ~]#dd if=/home/xenvm01.img of=/dev/xenimg01/lvmxen01
    This process will take good amount of time. depending on resources available on server also. usually I have noticed it takes about 30 Minutes for image of 4GB.
  9. Once the command listed in above step completes successfully, we need to make a change in configuration file for dom-U. edit /etc/xen/xenvm01 file and change the disk parameter as mentioned below.
      name = "xenvm01"
      uuid = "056a8eb9-c5e8-dc42-1f5a-a048d9a58f74"
      maxmem = 512
      memory = 512
      vcpus = 1
      bootloader = "/usr/bin/pygrub"
      on_poweroff = "destroy"
      on_reboot = "restart"
      on_crash = "restart"
      vfb = [ ]
      disk = [ "phy:/dev/xenimg01/lvmxen01,xvda,w" ]
      vif = [ "mac=00:16:3e:1f:c3:a4,bridge=xenbr0" ]
    As specified disk value need to be changed from disk = [ "tap:aio:/home/xenvm01.img,xvda,w" ] to disk = [ "phy:/dev/xenimg01/lvmxen01,xvda,w" ]
  10. Now start the guest os with following command
    xm create -c xenvm01. This will start your dom-U guest from logical volume /dev/xenmg01/lvmxen01
  11. Hope this article will help lots of other people as it helped a lot to me.

Sunday, 2 May 2010

BGP Essentials: Configuring Internal BGP Sessions

Internal BGP (IBGP) sessions (BGP sessions within your autonomous system) are identified by the neighbor’s AS number being identical to your AS number. While the external BGP (EBGP) sessions are usually established between directly-connected routers, IBGP sessions are expected to be configured across the network.

The current best practice is to configure IBGP sessions between the loopback interfaces of the BGP neighbors, ensuring that the TCP session between them (and the BGP adjacency using the TCP session) will not be disrupted after a physical link failure as long as there is an alternate path toward the adjacent router.

To configure IBGP session on a Cisco router, specify the neighbor’s loopback address in all neighbor commands and use the neighbor update-source command to specify the source IP address of the TCP session. Without the neighbor update-source configuration command, the TCP session will use the IP address of the outgoing physical interface and the neighbor will reject the incoming TCP SYN packet as it’s not coming from a recognized BGP neighbor.

The following table shows the configuration commands necessary to configure an IBGP session between loopback interfaces of two routers:

AS 11

AS 12

interface Loopback 0
ip address 10.0.0.1
!
router bgp 65001
neighbor 10.0.0.2 remote-as 65001

interface Loopback 0
ip address 10.0.0.2
!
router bgp 65001
neighbor 10.0.0.1 remote-as 65001
neighbor 10.0.0.1 update-source loopback 0