Linux Virtual machine--KVM installation and configuration

Source: Internet
Author: User
Tags connect socket gpg

First, configure the environment

Package Group:

Virtualization provides the environment for virtual machines, mainly including QEMU-KVM

Virtualization-client manages and installs the virtual machine instance client, mainly has the Python-virtinst,virt-manager,virt-viewer

Virtualization-platform provides access to and control over the virtual client interface, mainly libvirt,libvirt-client

Virtualization-tools Tools for managing offline virtual machine mirroring, mainly libguestfs

# Cat/proc/cpuinfo |GREP flags requires full virtualization support for VMX (Inter) or SVM (AMD)

Second, configure local Yum source

[[Email protected]Yum. repos.d]#CatLocal.repo [Rhel_6_iso]name=Local Isobaseurl=file:///MediaGpgcheck=1Gpgkey=file:///Media/rpm-gpg-key-redhat-release[Highavailability]name=Highavailabilitybaseurl=file:///media/highavailabilitygpgcheck=1Gpgkey=file:///Media/rpm-gpg-key-redhat-release[Loadbalancer]name=Loadbalancerbaseurl=file:///Media/loadbalancergpgcheck=1Gpgkey=file:///Media/rpm-gpg-key-redhat-release[Resilientstorage]name=Resilientstoragebaseurl=file:///Media/resilientstoragegpgcheck=1Gpgkey=file:///Media/rpm-gpg-key-redhat-release[Scalablefilesystem]name=Scalablefilesystembaseurl=file:///Media/scalablefilesystemgpgcheck=1Gpgkey=file:///Media/rpm-gpg-key-redhat-release

Third, install the KVM package

Yum " Virtualization " " Virtualization Client " " virtualzation Platform " -y

Iv. installation of virtual machines

1. Configure the NIC Bridge

Since KVM creates a virtual machine, the network defaults to NAT mode, which will allow virtual machines to access the external network, the external network cannot access the virtual machine, and for the external network to communicate properly with the virtual machine, where the NIC Bridge is configured, and the virtual machine is created using a bridged network.

# cd/etc/sysconfig/network-scripts/# CPIfcfg-eth0 ifcfg-br0#Catifcfg-eth0 DEVICE="eth0"Bootproto="Static"#DNS1="192.168.62.110"#HWADDR="00:50:56:25:ae:19"#IPADDR="192.168.62.201"#IPV6INIT="Yes"#NETMASK="255.255.255.0"#NM_CONTROLLED="Yes"Onboot="Yes"TYPE="Ethernet"BRIDGE=br0#Catifcfg-br0 DEVICE="br0"Bootproto="Static"DNS1="192.168.62.110"ipaddr="192.168.62.201"Ipv6init="Yes"NETMASK="255.255.255.0"nm_controlled="Yes"Onboot="Yes"TYPE="Bridge"

After restarting the NIC, you can see that the eth0 and the Br0 establish a bridging

#/etc/init.d/network restartshutting down interface Eth0:bridge BR0 does not exist![OK]shutting down interface eth1: [OK]                            Shutting down loopback interface: [OK]bringing up Loopback interface: [OK]  Bringing Up interface eth0: [OK]bringing up interface eth1:determining IP information  forEth1 ... Done. [OK] Bringing Up interface br0:determiningifIP Address192.168.62.201is alreadyinchUse forDevice Br0 ... [OK] [[Email protected] network-scripts]# IP a1: Lo: <LOOPBACK,UP,LOWER_UP> MTU65536qdisc noqueue State UNKNOWN Link/loopbackxx:xx:xx:xx:xx:xxBrdxx:xx:xx:xx:xx:xxinet127.0.0.1/8Scope host lo inet6::1/ -Scope host Valid_lft forever Preferred_lft forever2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> MTU theQdisc Pfifo_fast State up Qlen +Link/etherxx: -: About: -: AE: +BRD ff:ff:ff:ff:ff:ff inet6 fe80:: -: 56ff:fe25:ae19/ -scope link Valid_lft forever Preferred_lft forever3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> MTU theQdisc Pfifo_fast State up Qlen +Link/etherxx: 0c: in: the: 3b:ef BRD ff:ff:ff:ff:ff:ff inet192.168.1.63/ -Brd192.168.1.255Scope Global eth1 Inet6 fe80::20c:29ff:fe68:3bef/ -scope link Valid_lft forever Preferred_lft forever4: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> MTU theqdisc noqueue State UNKNOWN Link/etherxx: -: About: -: AE: +BRD ff:ff:ff:ff:ff:ff inet192.168.62.201/ -Brd192.168.62.255Scope Global Br0 inet6 FE80:: -: 56ff:fe25:ae19/ -scope link Valid_lft forever preferred_lft forever[[email protected] Network-scripts]# brctl Showbridge name BridgeIDSTP enabled Interfacesbr08000.00505625AE19 no Eth0

2. Create a virtual machine

# virt-Install --vcpus=1 --os-variant=rhel6--accelerate--cdrom=/dev/sr0--disk path=/ Opt/kvmimg/vm01.img,size=5, Bus=virtio--bridge=br0,model=virtio--autostart--vnc--vncport=5900 --vnclisten=0.0. 0.0 ERROR     Locate  in/usr/sbin (to override, set $LIBVIRTD _path to the name of the LIBVIRTD binary)

This prompt is incorrect because libvirt is not installed.

Yum Install libvirt*-y
#/etc/init.d/libvirtd startstarting libvirtd daemon:                                  [  OK  ]

After installation is complete and started, otherwise error Failed to connect socket to '/var/run/libvirt/libvirt-sock ': No such file or directory

Re-create the virtual machine

# virt-Install--name vm01--boot Network,cdrom,menu=on--ram +--vcpus=1--os-variant=rhel6--accelerate--cdrom=/dev/sr0--disk path=/opt/kvmimg/vm01.img,size=5, Bus=virtio--bridge=br0,model=virtio--autostart--vnc--vncport=5900--vnclisten=0.0.0.0startingInstall... Creating StoragefileVm01.img |5.0GBxx:xxCreating Domain ... |0Bxx:xxcannot open Display:run'Virt-viewer--help'To see a full list of available command line Optionsdomain installation stillinchprogress. You can reconnect to the console to complete the installation process.

For virt-intall detailed parameters see the KVM virt-install command option parameter description

At this point, you can use the VNC client connection < host ip>:5900 to install the system using the graphical interface. The installation process ignores

Linux Virtual machine--KVM installation and configuration

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.