Install and configure KVM on centos 6.3

Source: Internet
Author: User
Tags svm centos server ide hard drive

Job Environment

Server

Operating System: centos 6.3 final x86_64

IP: 133.133.10.50

Hostname: mykvm

KVM: qemu-kvm-0.12.1.2-2.295.el6_3.2.x86_64

Client: Ubuntu and win7. First, install VNC on the server and connect to the centos server through VNC.

1. Install KVM and related software

1. KVM requires CPU support (Intel vmx or amd svm). Check whether the CPU supports Virtual Technology before installing KVM:

[Root @ mykvm ~] # Egrep '^ flags. * (vmx | SVM)'/proc/cpuinfo

If there is a display, the processor has the VT function.

2. enable virtual lege (Vt, virtualization technology) of the CPU in the BIOS of the motherboard)

3. Install KVM and the required software packages
[Root @ mykvm ~] # Yum install KVM kmod-KVM qemu KVM-qemu-IMG virt-Viewer virt-manager libvirt-Python-kernel Inst

Or

[Root @ mykvm ~] # Yum groupinstall KVM

4. Check whether the KVM module is installed. If you use the following command to display the two modules, the installation is complete.

[Root @ mykvm ~] # Lsmod | grep KVM

Kvm_intel 52570 0

KVM 314739 1 kvm_intel

2. Start the virt-Manager Management Interface

1. Client

VNC to the server, because you need to use the server's graphical interface

2. Server Side



Start the libmongod service and make sure it is automatically started next time.

[Root @ mykvm ~] # Service libmongod start

Starting libmongod daemon: [OK]

[Root @ mykvm ~] # Chkconfig libmongod on

3. remotely create and manage KVM virtual machines

1. open application => system tools => Virtual Machine manager to install virtual machines. The functions are similar to those of VMware.


2. You can view or modify the configuration information of guest OS in "details ".

3. After the installation is complete, replace the default IDE hard drive and NIC with virtio and add the driver to improve the performance. (It seems like this by default)

 

4. During remote management of KVM Virtual Physical hosts, Vm memory can be dynamically adjusted to achieve clone, startup, shutdown, host suspension, and other operations.

5. Run the virsh LIST command on the server to view the host virtualization status.

[Root @ mykvm ~] # Virsh list

ID name state

----------------------------------------------------

1 centoskvm running

I installed a centos Virtual Machine on mykvm and named it centoskvm.

 

8. The information of the KVM virtual machine is stored in the/var/lib/libvirt directory.

Iii. Default KVM Network Configuration

1. Two configurations are available for KVM to access the Internet. One is default, which supports mutual access between hosts and virtual machines. It also supports virtual machines to access the Internet, but does not support external access to virtual machines. Another method is bridge. You can use a virtual machine to become a host with an independent IP address in the network.

4. Configure bridge Internet access

1. Create a bridge

In the/etc/sysconfig/network-scripts directory, create a ifcfg-br0 file whose type is set to bridge:

[Root @ mykvm libvirt] # Cat/etc/sysconfig/network-scripts/ifcfg-br0

Device = "br0"

Type = "bridge"

Bootproto = "static"

# Hwaddr = "00: 23: AE: 72: 50: 90"

Nm_controlled = "yes"

Onboot = "yes"

# Type = "Ethernet"

Ipaddr = 133.133.10.50

Netmask = 255.255.0.0

2. Bridge the physical interface to the bridge

Modify eth0 content (this server uses eth0 to access the Internet), remove its IP information, and add "bridge = br0" to bridge it to br0; if it is a dual or multi-nic, modify as follows:

[Root @ mykvm libvirt] # Cat/etc/sysconfig/network-scripts/ifcfg-eth0

Device = "eth0"

Bootproto = "static"

Hwaddr = "00: 23: AE: 72: 50: 90"

Nm_controlled = "yes"

Onboot = "yes"

Type = "Ethernet"

# UUID = "18ffa985-2081-4be5-951b-fb0d136741bf"

# Ipaddr = 133.133.10.50

# Netmask = 255.255.0.0

Bridge = br0

3. Restart the network service of the Physical Machine

[Root @ etone ~] # Service network restart

4. view the current bridging status (one virtual machine is running)

[Root @ mykvm libvirt] # brctl show

Bridge name bridge id stp enabled Interfaces

Br0 8000.0023ae725090 no eth0

Virbr0 8000.525400efd043 Yes virbr0-nic

Vnet0

5. Bridge the virtual machine interface to the bridge

[Root @ mykvm ~] # Brctl delif virbr0 vnet0

[Root @ mykvm ~] # Brctl addif br0 vnet0

[Root @ mykvm ~] # Brctl show

[Root @ mykvm libvirt] # brctl show

Bridge name bridge id stp enabled Interfaces

Br0 8000.0023ae725090 no eth0

Vnet0

Virbr0 8000.525400efd043 Yes virbr0-nic

This step can also be performed in Virtual Machine manager.

6. Set the Virtual Machine centoskvm IP address to the same CIDR block address: 133.133.10.51

In this case, the VM can access the external network and be accessed by the external network.

Servers can connect to virtual machines

[Root @ mykvm libvirt] # Ping 133.133.10.51

Ping 133.133.10.51 (133.133.10.51) 56 (84) bytes of data.

64 bytes from 133.133.10.51: icmp_seq = 1 TTL = 64 time = 0.700 MS

64 bytes from 133.133.10.51: icmp_seq = 2 TTL = 64 time = 0.093 MS

64 bytes from 133.133.10.51: icmp_seq = 3 TTL = 64 time = 0.072 MS

^ C

--- 133.133.10.51 Ping statistics ---

3 packets transmitted, 3 bytes ed, 0% packet loss, time 2137 Ms

RTT min/AVG/max/mdev = 0.072/0.288/0.700/0.291 MS

Virtual machines can connect to the Internet [root @ centoskvm ~] # Ping 133.133.10.50ping 133.133.10.50 (133.133.10.50) 56 (84) bytes of data.64 bytes from 133.133.10.50: icmp_seq = 1 TTL = 64 time = 0.090 ms64 bytes from 133.133.10.50: icmp_seq = 2 TTL = 64 time = 0.075 Ms ^ C --- 133.133.10.50 Ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1492 msrtt min/AVG/max/mdev = 0.075/0.082/0.090/0.011 MS [root @ centoskvm ~] # Ping route 133.133.133.53 (133.133.133.53) 56 (84) bytes of data.64 bytes from 133.133.133.53: icmp_seq = 1 TTL = 64 time = 2.14 ms64 bytes from 133.133.133.133.53: icmp_seq = 2 TTL = 64 time = 0.323 Ms ^ C --- 133.133.133.53 Ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1836 msrtt min/AVG/max/mdev = 0.323/1.235/2.147/0.912 MS

Related Article

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.