Install KVM on CentOS 7 and create a virtual machine
Use KVM (kernel-based Virtual Machine) + QEMU virtualization. Requires a CPU that has Intel VT or AMD-V functionality.
[Root @ kvm-centos7 ~] # Yum-y install qemu-kvm libvirt virt-install bridge-utils # ensure the module has been loaded [root @ kvm-centos7 ~] # Lsmod | grep kvm kvm_intel 170181 0 kvm 554609 1 kvm_intelirqbypass 13503 1 kvm [root @ kvm-centos7 ~] # Systemctl start libmongod [root @ kvm-centos7 ~] # Systemctl enable libvirtd
- Configure a bridge network for a KVM Virtual Machine
Reference: http://blog.csdn.net/wh211212/article/details/54135565
Lab environment: OS: CentOS Linux release 7.3.1611 (Core) Network: Dual-nic bonding hardware: DELL R420, 16 GB, 1 CPU, 4 Cores
# Nic configuration, create ifcfg-bro, and then modify the related configuration as follows: [root @ kvm-centos7 ~] # Cd/etc/sysconfig/network-scripts/[root @ kvm-centos7 network-scripts] # cat ifcfg-br0 DEVICE = "br0" ONBOOT = "yes" TYPE = "Bridge" BOOTPROTO = staticIPADDR = 192.168.1.20.# custom NETMASK = 255.255.255.0GATEWAY = 192.168.1.1DEFROUTE = yes # ifcfg-bond0 configuration file modification [root @ kvm-centos7 network-scripts] # cat ifcfg-bond0 DEVICE = bond0TYPE = EthernetNAME = bond0BONDING_MASTER = yesBOOTPROTO = noneBRIDGE = br0ONBOOT = yesBONDING_OPTS = "mode = 5 miimon = 100"
After the bridging network configuration is complete, restart the network service. See ifconfig as follows:
[root@kvm-centos7 network-scripts]# systemctl restart network
Check ifconfig to see if the network service is normal
Create a virtual machine
Install GuestOS and create a virtual machine. This example shows how to install CentOS 7
- By using the network to install GuestOS in text mode, Virtual Machine images are stored in/var/lib/libvirt/images by default as storage pools. However, this example shows how to create and use a new storage pool.
[Root @ kvm-centos7 ~] # Mkdir-p/var/kvm/images # create a new storage pool [root @ kvm-centos7 ~] # Virt-install \ -- name elk \ -- ram 4096 \ -- disk path =/var/kvm/images/elk. img, size = 30 \ -- vcpus 2 \ -- OS-type linux \ -- OS-variant rhel7 \ -- network bridge = br0 \ -- graphics none \ -- console pty, target_type = serial \ -- location 'HTTP: // mirrors.aliyun.com/centos/7/ OS /x86_64/' \ -- extra-args 'console = ttyS0, 115200n8 serial'
The normal loading status is as follows:
The meanings of the parameters specified above are as follows: For more information, see man virt-install.
-- Name specifies the Virtual Machine name -- ram specifies the Virtual Machine -- disk memory size path = xxx, size = XXX' path = 'specify Virtual Machine size = 'specify the number of disks of the Virtual Machine in bytes -- vcpus specify virtual CPU -- OS-type specify the type of GuestOS -- OS-variant specify the type of GuestOS -Check whether the following command osinfo-query OS -- network is used in the list to specify the network type of the VM -- graphics to specify the image type. If it is set to "NONE", it means non-graphics. -- Console specifies the console type -- location specifies the installation location, where from -- extra-args specifies the parameters set in the kernel
- Installation in text mode is the same as common installation steps. After the installation is complete, restart the system, and the logon prompt is as follows.