1. Introduction to KVM
KVM is open source software, the full name is kernel-based virtualmachine (kernel-based virtual machine), is an open source system virtualization module, based on hardware full virtualization, but requires hardware support (such as Intel VT technology or AMD V technology). Since Linux 2.6.20, it has been integrated in all major Linux distributions. It uses Linux's own scheduler for management, so compared to Xen, its core source code is scarce. KVM has become one of the mainstream VMMs in academia.
Two, KVM installation configuration
1. CPU virtualization enabled
You need to enable virtualization in the BIOS, which is generally enabled by default
| cat /proc/cpuinfo | grep'vmx' //Intel CPU judgment method cat /proc/cpuinfo | grep'svm' //AMD CPU judgment method|
|--------|
2. Install KVM
yum install qemu-kvm qemu-kvm-tools virt-manager libvirt virt-viewer -y |
---|
Parameter explanation:
kvm: a module of the linux kernel, the module does not need to be installed, only needs to be loaded
qemu: virtualization software, which can virtualize different CPUs and supports heterogeneous
qemu-kvm: User mode management kvm, network cards, sound cards, PCI devices, etc. are all managed by qemu.
virt-viewer: A tool when using VNC client to connect to the server's graphical interface.
3. Load the kvm module
| modprobe kvm-intel //Load the kvm module lsmod | grep kvm //Check whether the kvm module is loaded|
|--------|
4. Modify the configuration file of the network card
**eth0 **
New br0
Don't worry about whether the IP addresses of the network cards are consistent or not, the role of eth0 now is similar to a switch. (No IP)
It is normal as shown below.
5. Modify the configuration file of the VNC server
Remove the # comment in front of vnc_listen = "0.0.0.0" // on line 12 of the file
vim /etc/libvirt/qemu.conf |
---|
6. Restart libvirtd and messagebus services
/etc/init.d/libvirtd restart //Restart libvirtd service /etc/init.d/messagebus restart //Restart messagebus service |
---|
7. Create virtual disk
Create a virtual disk, -f specifies the format, the path is /opt/CentOS-6.5-x86_64.raw, the size is 10G
qemu-img create -f raw /opt/CentOS-6.5-x86_64.raw 10G |
---|
8. Copy the image file to the directory and the virtual disk storage directory
Insert the server CD into cdrom1
dd if=/dev/cdrom1 of=/opt/Centos-6.5-x86_64.iso |
---|
9. Create a virtual machine
virt-install -n centos6.5 -r 512 -vcpus=1 -s 50 -c /opt/Centos6.5-x86_64.iso --hvm --os-type=linux -f /opt/CentOS-6.5-x86_64.raw --graphics vnc,listen=0.0.0.0,port=7789 --force --autostart |
---|
Parameter explanation:
Create a virtual machine called centos6.5, the memory size is 512 memory, 1 cpu, 50G hard disk, the installation image is /opt/Centos6.5-x86_64.iso designated as full virtualization, the system type is designated as linux virtual The hard disk of the machine is opt/CentOS-6.5-x86_64.raw, and the port of vnc is configured as 7789 to automatically start the installation.
Verification: virshlist
10. Set iptables security policy
iptables -I INPUT -p tcp --dport 7789 -j ACCEPTservice iptables save |
---|
11. Use VNC client to connect to KVM virtual machine
If your Xshell will automatically pop up this window, it is also possible. If not, you can close it and use VNC to connect.
Enter the IP address and port
start installation
12. Configure KVM virtual machine
For example, install an Apache web-server
Configure IP address
Use Xshell to connect (a simple example of yum method)
Start httpd service
**Browser access test ok! **
Recommended Posts