CentOS 7 install KVM and create a virtual machine

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

Create a virtual machine##

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

Reinstall the kvm virtual machine and record the installation steps##

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.

Attached below is the author's network card configuration information##

[ 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

CentOS 7 install KVM and create a virtual machine
Install KVM on CentOS 7 and create a virtual machine
Download of VM virtual machine and install centos7
VMwareWorkstation10.0 install CentOS7.0 virtual machine
How to create a CentOS virtual machine in VMware
How to create a CentOS virtual machine in VMware
Centos6.3 install KVM
Install CentOS7 virtual machine, configure docker suite
Install centos7 and connect
003.KVM virtual machine deployment-CentOS6.8
Install Ubuntu on VMware virtual machine and install using UltraISO
Install ubuntu on virtual machine
centos7 install python3 and ipython
Know Linux and install CentOS
CentOs7.3 compile and install Nginx 1.9.9
CentOS 7 install Mono and MonoDevelop
CentOS6.5 install Java 8 and Tomcat8
Centos compile and install Git
Linux CentOS 7 virtual machine clone
CentOS7 install python3 and pip3
Virtual machine VirtualBox-5.1 install ubuntu16.0.1
CentOS 6.8 virtual machine installation details
CentOS6.5 install Java 8 and Tomcat8
CentOS6 install and crack Jira 7
CentOS6.5 install Java 8 and Tomcat8
Centos7 compile and install ntp-4.2.8p11
CentOS 6.9 compile and install python
CentOS6 install and crack confluence
CentOS 6 compile and install python 3
CentOS6 install and crack Jira 7
How to install Centos operating system on VMware virtual machine
Centos 7 install jdk and package service service
CentOS7 yum install and start mysql
Install and configure keepalived under CentOS 5.9
CentOS Yum compile and install MySQL 5.6
Compile and install LAMP under Centos 5.2
CentOS 8 install Git and basic configuration
CentOS 6.x compile and install Nginx
CentOS7 compile and install L(A|N)MP environment
CentOS7.2 and Nginx configuration virtual host
CentOS7.3 install iptables and detailed use
CentOS quickly install Python3 and pip3
CentOS7 yum install and start mysql
CentOS 8 - install and configure NFS service
Centos7 and centos8 install mysql5.6 5.7 8.0 so simple
Centos7 uninstall openJdk, and install JDK1.8
Install Python3 and ansible under CentOS8
Install and use docker under CentOS 6.8
CentOS7 install and use SQL Server
CentOS Minimal install and configure TIPS
Install Python3 and Py under CentOS7
Install and configure FreeIPA in Centos7
Linux CentOS6 compile and install Pyt
virtualBox install centos, and build tomcat
Install Mono 3.2 and Jexus 5.4 under CentOS 6.3
Detailed steps to install virtual machines with VMware 15 and use CentOS 8
CentOS7.5 source code compile and install mysql5.7.29
Centos7 compile and install MySQL8 problem record
Install Ubuntu 18.04 in the virtual machine VMware
Install Mono 2.10.8 and Jexus 5.0 under 32- and 64-bit CentOS 6.0
1.5 Install Centos7