Installation and daily management of KVM virtual machines

Source: Internet
Author: User

To save costs, the company needs to migrate some of its services to the virtualization platform. Today, we have installed the virtual machine and take notes.


1. system installation on the Physical Machine (Hard Disk: 300 GB + 300 GB ):

Centos6.5 64-bit. If the desktop environment is not installed, the default running level is 3 partitions: /boot 128 mswap 8g/20g/data1 first hard disk space remaining/data2 second hard disk space used to minimize installation + The following software package: basesystem -- basedevelopment -- development tools to configure DNS to determine the system time and Beijing time synchronization server to allow command restart (automatically completed). If self-check is required, Press F1 manually. Remove the self-check from the machine) enable VT in BIOS


2. Install the KVM environment:

yum -y install kvm python-virtinst libvirt tunctl bridge-utils virt-manager qemu-kvm-tools virt-viewer virt-v2v libguestfs-tools/sbin/service libvirtd restartln -s /usr/libexec/qemu-kvm /usr/bin/qemu-kvm

Create a bridge: CAT/etc/sysconfig/network-scripts/ifcfg-br0

Device = br0type = bridgeonboot = yesbootproto = staticipaddr = Public IP netmask = Public IP mask gateway = Public IP Gateway

Modify Nic information to connect Nic to bridge: CAT/etc/sysconfig/network-scripts/ifcfg-em1

DEVICE=em1BRIDGE=br0ONBOOT=yesBOOTPROTO=none

Restart NIC:

service network restart

View bridges:

[[email protected] data1]# brctl show  bridge name     bridge id               STP enabled     interfacesbr0             8000.d4ae526e935a       no              em1virbr0          8000.525400efec1a       yes             virbr0-nic

So far, the installation of the KVM environment is complete. Next, create a new virtual machine to install the operating system.


3. Upload ISO (omitted)


4. Create a virtual machine:

Create a disk:

qemu-img create -f qcow2 centos01.img 120Gvirt-install --name=centos01  --ram 4096 --vcpus=2 --disk path=/data1/centos01.img,format=qcow2,size=120,bus=virtio --accelerate --cdrom /data1/CentOS-5.8-x86_64-bin-DVD-1of2.iso  --vnc --vncport=5910 --vnclisten=0.0.0.0 --network bridge=br0,model=virtio --noautoconsole

-- Name: Specifies the Virtual Machine name.

-- Memory size allocated by Ram.

-- Vcpus allocates the number of CPU cores, which is the same as the maximum number of CPU cores on the physical machine.

-- Disk specifies the virtual machine image, and size specifies the allocation size in G.

-- Network type. The default network type is used here. Generally, bridge bridging is used.

-- Accelerate Acceleration

-- CDROM specifies the installation image ISO

-- VNC enables VNC remote management. Generally, it must be enabled for installation systems.

-- Vncport specifies the VNC monitoring port. The default port is 5900, and the port cannot be repeated.

-- Vnclisten specifies that the VNC is bound to an IP address. 127.0.0.1 is bound by default. Here, it is changed to 0.0.0.0.

If no accident occurs, the system starts the 5910 terminal for VNC connection.

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/44/52/wKioL1PgmI6SgzQRABQq-OXhZBE048.bmp "Title =" 1.bmp "alt =" wKioL1PgmI6SgzQRABQq-OXhZBE048.bmp "/> then you can use the VNC client to connect to the installation system, the same as the machine room to connect to the monitor, if the VNC client is disconnected, set colourlevel to rgb222, for example:

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/44/52/wKiom1PgmDbBfmd6AAaFKH1bIGQ742.bmp "Title =" 2.bmp "alt =" wkiom1pgmdbbfmd6aaafkh1bigq742.bmp "/>


5. Install the Operating System (omitted)


6. daily management of KVM:

View the KVM list: virsh list -- all


Start KVM: virsh start centos01

Disable KVM: virsh shutdown centos01

Force disable KVM: virsh destroy centos01

Pause KVM: virsh suspend centos01

Restore KVM: virsh resume centos01


Clone KVM: virt-clone-O centos01-N centos02-F/data1/centos02.img


Edit KVM configuration: virsh edit centos01


Delete the VNC Port:

Virsh edit centos01, open XML, and delete the following Configuration:

    <graphics type=‘vnc‘ port=‘5910‘ autoport=‘no‘ listen=‘0.0.0.0‘>      <listen type=‘address‘ address=‘0.0.0.0‘/>    </graphics>


Set the Automatic startup of KVM upon startup: vrish autostart centos01


After a day of touch, I almost got in touch with this. I will try again later!

This article is from the "O & M notes" blog, please be sure to keep this source http://lihuipeng.blog.51cto.com/3064864/1536038

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.