KVM Virtualization in RHEL 6

1. Install the following packages for setting up  guest hosts using KVM virtualization .

                    # yum install  virt-install  virsh  libvirt  kvm

                     # yum install kvm python-virtinst libvirt libvirt-python virt-manager
                     # yum install virt-viewer libguestfs-tools

2.   Check whether the following modules are loaded . If not , load it manually using insmod. 

# modinfo kvm
filename:       /lib/modules/2.6.32-220.el6.x86_64/kernel/arch/x86/kvm/kvm.ko
license:        GPL
author:         Qumranet
srcversion:     E0EC656A576974AAE72808D
vermagic:       2.6.32-220.el6.x86_64 SMP mod_unload modversions
parm:           oos_shadow:bool
parm:           ignore_msrs:bool
parm:           allow_unsafe_assigned_interrupts:Enable device assignment on platforms without interrupt remapping support. (bool)


# modinfo kvm_intel
filename:       /lib/modules/2.6.32-220.el6.x86_64/kernel/arch/x86/kvm/kvm-intel.ko
license:        GPL
author:         Qumranet
srcversion:     0B88774FBBF6ECB64244D3A
depends:        kvm
vermagic:       2.6.32-220.el6.x86_64 SMP mod_unload modversions
parm:           bypass_guest_pf:bool
parm:           vpid:bool
parm:           flexpriority:bool
parm:           ept:bool
parm:           unrestricted_guest:bool
parm:           emulate_invalid_guest_state:bool
parm:           yield_on_hlt:bool
parm:           ple_gap:int
parm:           ple_window:int  

3.  Restart libvirtd service

               # /etc/init.d/libvirtd restart
               Stopping libvirtd daemon:                                  [FAILED]
               Starting libvirtd daemon:

                                              Setting Up Networking

1.   Create a new br0 network device of TYPE Bridge using system-config-network command or  
      create it manually as shown below. Assign IP Address and other network configuration details 
      based on your requirement.  
        # vim /etc/sysconfig/network-scripts/ifcfg-br0
          NAME="System br0"
2.   Modify the original network configuration file (e.g /etc/sysconfig/network-scripts/ifcfg-eth0 )     
     and comment out BOOTPROTO , IPADDR  , PREFIX and GATEWAY parameters . Add 
      the following network parameter and restart network service .                                       
     So , the final eth0 network interface file will be as follows

       $ cat /etc/sysconfig/network-scripts/ifcfg-eth0

3. Restart network service

        #/etc/init.d/network restart

If all went fine your network configuration will be as follows: 

 # ifconfig

eth0     Link encap:Ethernet  HWaddr 44:1E:A1:55:B0:B0
          RX packets:724970 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8032 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:239225199 (228.1 MiB)  TX bytes:1348488 (1.2 MiB)

br0       Link encap:Ethernet  HWaddr 44:1E:A1:55:B0:B0
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::461e:a1ff:fe55:b0b0/64 Scope:Link
          RX packets:22 errors:0 dropped:0 overruns:0 frame:0
          TX packets:30 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:3898 (3.8 KiB)  TX bytes:3196 (3.1 KiB)

lo        Link encap:Local Loopback
          inet addr:  Mask:
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:2794116 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2794116 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:260264756 (248.2 MiB)  TX bytes:260264756 (248.2 MiB)


                                 Creating the Guest Hosts

There are two tools available for creating  guest hosts . One is virt-manager tool which has a graphical interface and the other is virt-install tool which has a text interface . We will be using virt-install tool to setup guest hosts. 

For our case , we will be creating a virtual hosts with 3 GB of RAM , 3 no of CPUs  and with a hard disk space of 20G . The command will be as follows:

  # virt-install --network bridge=br0 \

                      --name  vm-dbase   \

                      --ram=3072  \

                      --vcpus=3  \

                      --disk path=/var/lib/libvirt/images/vm1-mysql.img,size=20  \

                     --graphics none   \

                     --location=  \

                     --extra-args="console=tty0 console=ttyS0,115200"  \

                     --os-type=linux  \


 Little description is as follows:

       --vcpus= Number of virtual cpus to configure for the guest. 

       --location=An HTTP server location containing an installable distribution image

       --disk=Specifies media to use as storage for the guest, with various options including size of disk 

       --name=Name of the new guest virtual machine instance.     

Press Enter and here you go , creation of virtual host will get initiated  . Follow the on-screen instructions for setting up the OS . These are the standard instructions we need to pass through while installing Linux . Once you are done providing all the parameters , a minimal OS installation will be done. The Guest host will be rebooted after installation is complete and you will be provided with a login prompt to login into the guest operating system .

  NOTE: Setting up a  HTTP based Linux installation Server is available as a blog article at       setting-up-local-yum-repository



Popular posts from this blog

How to add check_http as a service in Nagios Monitoring using NRPE

PSSH : Parallel SSH to execute commands on a number of hosts

Using lsof to identify deleted files: