Server Virtualization with CentOS
CentOS Linux includes KVM and other software needed for managing virtual machines. This post shows how to create a virtual machine with an iSCSI storage backend.
Install OS
Download the latest version from the CentOS web site and perform an install. Select the "minimal" install set.
Linux KVM performs much better if your hardware supports virtualization. Verify that your hardware is supported by running the following command:
grep "vmx|svm" /proc/cpuinfo
Configure Network
Configure eth0 as a management interface. Configure eth1 and eth2 for iSCSI. Configure eth3 for VM traffic. Split iSCSI interfaces between the onboard NIC and PCI adapter for redundancy.
Define network for libvirt.
[code language="xml"] <network> <name>testnet</name> <forward mode='bridge'/> <bridge name='br0'/> </network> [/code]
Install Virtualization Software
Install Linux KVM, QEMU, libvirt. Reboot when you are finished.
yum update yum groupinstall Virtualization "Virtualization Platform"
Configure Storage
For more information on building a storage server, check out this related post: Building a Storage Server with OpenIndiana.Install iSCSI and multipath software.
yum install iscsi-initiator-utils device-mapper-multipath mpathconf --enable
Edit /etc/multipath.conf and set user_friendly_names to no.
Start multipathd.
chkconfig --level 345 multipathd on service multipathd start
Discover iSCSI targets on 10.3.0.10.
iscsiadm -m discovery -t st -p 10.3.0.10 iscsiadm -m session
Check multipath.
multipath -ll
Manually define our storage pools with the XML below and virsh pool-define:
[code lang="xml"] <pool type="iscsi"> <name>iscsipool</name> <source> <host name="10.3.0.10"/> <device path="iqn.2010-09.org.openindiana:02:c379"/> </source> <target> <path>/dev/disk/by-path</path> </target> </pool>
<pool type="mpath"> <name>virtpool</name> <target> <path>/dev/mapper</path> </target> </pool> [/code]
Adding Virtual Machines
Use the following command to create a virtual machine.
virt-install --name newvm --hvm --vcpus 1 --ram 512 --network \ network:br0,mac=52:54:00:aa:cc:00 --disk /dev/mapper/mylun,bus=virtio --vnc
To connect to the console use virt-manager or any VNC client.