Linux operation and maintenance --KVM set up and simple to use

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/AMimiDou_212/article/details/102465386


I. Introduction: KVM virtualization technologies

KVM (Kernel-based Virtual Machine) for short, is an open source system virtualization module, since Linux 2.6.20 is integrated in each major release of Linux. It uses the Linux scheduler to manage itself, so relative to Xen, the core source code rarely. KVM has become one of the mainstream VMM academia.
KVM requires hardware virtualization support (Intel VT technology, such as technology or AMD V). It is completely hardware-based virtualization . More commonly used commercial system virtualization software VMware ESX series is software-based simulation Full-Virtualization. The other is the VirtualBox virtualization, its open source free, simple and approachable.
As the demand I need to learn to use KVM virtual server build, simple to install and use KVM virtual machine creation process record today.

Second, pre-installation preparation

  1. Host hardware resources - allocating virtual machine
  2. CentOS 7 operating system - deployed KVM
  3. Image file CentOS 7 - providing KVM installation package
  4. Configure the local YUM repository source - Linux source configuration YUM

Three, KVM installation process

1. Installation with qemu-kvm libvirt

[root@localhost ~]# yum install -y qemu-kvm libvirt  # qemu-kvm 创建虚拟机硬盘 与 libvirt 虚拟机管理工具 

2. Installation virt-install

[root@localhost ~]# yum install -y  virt-install  #  virt-install 虚拟机创建工具

3. Start libvirtd service and add startup items, default view card information through the ifconfig command, will add a virbr0 the card, ip default 192.168.122.1/24 (if it is a virtual machine created by VMware software, the default created this card, and start libvirtd service, not physical machine)

[root@localhost ~]# systemctl start libvirtd   # 启动 libvirtd 虚拟机管理服务
[root@localhost ~]# systemctl enable libvirtd  # 加入开机启动项
[root@localhost ~]# systemctl daemon-reload  # 重新加载系统服务
[root@localhost ~]# systemctl is-enabled libvirtd  # 查看是否成功加入开机自启
 enabled

At this point, KVM installation is complete, you can create a new virtual machine.

Fourth, the use KVM to create a new virtual machine

1. Create a new virtual machine via virt-install

CentOS 1.1 server to upload image files

1.2 to create a virtual hard disk

[root@localhost ~]# qemu-img create -f qcow2 /kvm/centos-7.qcow2 10G   # 创建一个格式为qcow2 大小为10G的裸磁盘
Formatting '/kvm/centos-7.qcow2', fmt=qcow2 size=10737418240 encryption=off cluster_size=65536 lazy_refcounts=off
[root@localhost ~]# 

Create a hard disk Supported formats: Supported Formats: vvfat VPC VMDK vhdx VDI SSH Sheepdog rbd RAW host_cdrom host_floppy host_device File QED qcow2 qcow Parallels NBD iscsi Gluster DMG the TFTP HTTP HTTPS cloop the FTP FTPS Bochs blkverify blkdebug
which is qcow2 common format that supports multiple disk snapshots.
: All kinds of virtual disk format different from the format difference KVM disk mirroring qcow2, raw, vmdk, etc.

1.3 to create a new virtual machine

[root@localhost ~]# virt-install  --virt-type kvm --name CentOS-7 --ram 1024 --cdrom=/ISO/CentOS-7-x86_64-DVD-1810.iso --disk path=/kvm/centos-7.qcow2 --network network=default --graphics  vnc,listen=0.0.0.0 --noautoconsole  

#--virt-type kvm   使用的管理程序名称
#--name CentOS-7   #虚拟机名称 Domain
#--ram 1024 --cdrom=/ISO/CentOS-7-x86_64-DVD-1810.iso  #镜像源
#--disk path=/kvm/centos-7.qcow2   #虚拟硬盘
#--network network=default  #网络
#--graphics  vnc,listen=0.0.0.0    #配置虚拟机显示设置
#--noautoconsole    #不要自动尝试连接到客户端控制台

Starting install...
Domain installation still in progress. You can reconnect to
the console to complete the installation process.

1.4 interface to connect to the installation via vnc client, kvm virtual machine Default Port: 5900

Here Insert Picture Description
Then you can start the installation by VNC remote interface system.

2. Create a new virtual machine through virt-manager graphical interface - similar to the installation of VMware virtual machines.

Guess you like

Origin blog.csdn.net/AMimiDou_212/article/details/102465386