Install KVM Hypervisor on CentOS 7.x and RHEL 7.x
KVM is an open source hardware virtualization software through which we can create and run multiple Linux based and windows based virtual machines simultaneously. KVM is known as Kernel based Virtual Machine because when we install KVM package then KVM module is loaded into the current kernel and turns our Linux machine into a hypervisor.
In this post first we will demonstrate how we can install KVM hypervisor on CentOS 7.x and RHEL 7.x and then we will try to install virtual machines.
Before proceeding KVM installation, let’s check whether your system’s CPU supports Hardware Virtualization.
Run the beneath command from the console.
We should get the word either vmx or svm in the output, otherwise CPU doesn’t support virtualization.
Step:1 Install KVM and its associate packages
Run the following yum command to install KVM and its associated packages.
Start and enable the libvirtd service
Run the beneath command to check whether KVM module is loaded or not
In Case you have Minimal CentOS 7 and RHEL 7 installation , then virt-manger will not start for that you need to install x-window package.
Reboot the Server and then try to start virt manager.
Step:2 Start the Virt Manager
Virt Manager is a graphical tool through which we can install and manage virtual machines. To start the virt manager type the ‘virt-manager‘ command from the terminal.
Step:3 Configure Bridge Interface
Before Start creating VMs , let’s first create the bridge interface. Bridge interface is required if you want to access virtual machines from outside of your hypervisor network.
In cp command replace the interface name that suits to your system and then edit the Interface file and set followings:
Edit the Bridge file (ifcfg-br0) and set the followings:
Replace the IP address and DNS server details as per your setup.
Restart the network Manager Service to enable the bridge interface.
Note: By default, in CentOS 7 / RHEL 7 Network Manager service is enabled and if have made changes in network files then we must restart Network Manager service to make the changes into the effect. In Case network Manager service is disabled and stopped then we can use network service (systemctl restart network)
Check the Bridge interface using below command :
Step:4 Start Creating Virtual Machines.
Now Create Virtual Machine either from the command line using ‘virt-install‘ command or from GUI (virt-manager )
Let’s Create a virtual machine of “Windows Server 2012 R2” using virt-manager.
Start the “virt-manager”
Go to the File Option, click on “New Virtual Machine”
We will be using ISO file as installation media. In the next step Specify the path of ISO file.
Click on Forward.
Specify the Compute Resources : RAM and CPU as per your setup.
Click on Forward to proceed further.
Specify the storage Size of Virtual Machine, In my case I am using 25G.
In the Next step Specify the Name of Virtual Machine and select network as ‘ Bridge bro’
Click on Finish to start the installation.
Follow the screen instructions and complete the installation.
Creating a virtual Machine from Command Line:
Virtual Machines can be created from the console as well using ‘virt-install’ command. In the following example i going to virtual machine of Ubuntu 16.04 LTS.
Follow the instruction now and complete the installation.
In the above ‘virt-install’ command we have used following options :
- –name = <Name of the Virtual Machine>
- –file = <Location where our virtual machine disk file will be stored >
- –file-size = < Size of the Virtual Machine, in my case it is 20GB >
- –nonsparse = < Allocate the whole storage while creating>
- –graphics = < Specify the graphical tool for interactive installation, in above example I am using spice >
- –vcpu = < Number of virtual CPU for the Machine >
- –ram = < RAM size for the virtual Machine >
- –cdrom = < Virtual CD ROM which specify the installation media like ISO file >
- –network = < it is used to specify which network we will use for the virtual machine, in this example I am bridge interface>
- –os-type = < Operating system type like linux and window>
- –os-variant= <KVM maintains the OS variants like ‘fedora18′, ‘rhel6’ and ‘winxp’ , this option is optional and if you not sure about OS variant you can mentioned it as generic>
Once the Installation is completed we can access the Virtual Machine console from ‘virt-manager‘ as shown below.
That’s it, basic installation and configuration of KVM hypervisor is completed.
Tidak ada komentar:
Posting Komentar