Virtualization using KVM (Kernel-based Virtual Machine) + QEMU. A CPU with Intel VT or AMD-V function is required.
[ root@kvm-centos7 ~]# yum -y install qemu-kvm libvirt virt-install bridge-utils
# Make sure the module is loaded
[ root@kvm-centos7 ~]# lsmod | grep kvm
kvm_intel 1701810
kvm 5546091 kvm_intel
irqbypass 135031 kvm
[ root@kvm-centos7~]# systemctl start libvirtd
[ root@kvm-centos7~]# systemctl enable libvirtd
Reference: http://blog.csdn.net/wh211212/article/details/54135565
lab environment:
OS:CentOS Linux release 7.3.1611 (Core)
Network: Dual network card bonding
Hardware: DELL R420, 16G 1CPU 4 cores
# Network card configuration, new ifcfg-bro, and then modify the relevant 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=static
IPADDR=192.168.1.133 #customize
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DEFROUTE=yes
# ifcfg-Bond0 configuration file modification
[ root@kvm-centos7 network-scripts]# cat ifcfg-bond0
DEVICE=bond0
TYPE=Ethernet
NAME=bond0
BONDING_MASTER=yes
BOOTPROTO=none
BRIDGE=br0
ONBOOT=yes
BONDING_OPTS="mode=5 miimon=100"
After the bridged network configuration is complete, restart the network service, check ifconfig as follows:
[ root@kvm-centos7 network-scripts]# systemctl restart network
Check ifconfig to see if the network service is normal
Install GuestOS and create a virtual machine. This example shows installing CentOS 7
[ 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 relevant parameters specified above are as follows: For more reference man virt-install
- - name specifies the name of the virtual machine
- - ram specifies Virtual Machine
- - Disk memory path= xxx,size = xxx
' path ='⇒Specify the virtual machine
size ='⇒Specify the number of disks of the virtual machine
- - vcpus specifies the virtual CPU
- - os-type specifies the type of GuestOS
- - os-variant specifies the type of GuestOS-It may be confirmed that the following command osinfo is used in the list-query os
- - network specifies the network type of the virtual machine
- - graphics specifies the type of graphics. If set to "None", it means non-graphics.
- - console specifies the console type
- - location specifies the location of the installation, where from--extra-args specifies the parameters set in the kernel
virt-install -d --virt-type=kvm --name=aniu-saas-1--vcpus=8--memory=12288--location=/media/CentOS-7-x86_64-Minimal-1611.iso --disk path=/dev/cl/aniu-saas-1--network bridge=br0 --graphics none --extra-args='console=ttyS0'--force
Note: The command line installation operation is more troublesome, please pay attention to the prompts.
[ root@aniu-saas network-scripts]# cat ifcfg-br0
DEVICE="br0"
TYPE="Bridge"
BOOTPROTO="none"
DEFROUTE="yes"
NAME="br0"
ONBOOT="yes"
IPADDR="192.168.0.205"
PREFIX="24"
GATEWAY="192.168.0.1"
DNS1="114.114.114.114"
[ root@aniu-saas network-scripts]# cat ifcfg-em1
TYPE="Ethernet"
NAME="em1"
UUID="999a275e-eac8-4323-bdf8-f7c7434b7737"
DEVICE="em1"
ONBOOT="yes"
BRIDGE="br0"
The successful installation interface is as follows:
[ root@localhost network-scripts]# cat ifcfg-eth0
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
NAME=eth0
UUID=a38ceceb-5f4e-4d08-a108-d83c176ea85b
DEVICE=eth0
ONBOOT=yes
IPADDR="192.168.0.206"
PREFIX="24"
GATEWAY="192.168.0.1"
DNS1="114.114.114.114"
Recommended Posts