Environment 1: Prepare 1.1 to check whether virtualization is supported
1 [[email protected] ~]# grep -E ‘vmx|svm‘ /proc/cpuinfo
Note: Intel is vmx and AMD is SVM.
1.2 determine host-related parameters
1 [[email protected] ~] # Cat/proc/cpuinfo | grep name | cut-D:-F2 | uniq-C # CPU Model 2 4 Intel (r) core (TM) i5-4690K CPU @ 3.50 GHz 3 [[email protected] ~] # Cat/proc/cpuinfo | grep physical | sort-N | uniq-C # Number of CPU Cores
2*2, that is, 4-core CPU.
1 [[email protected] ~] # Dmidecode | grep-A16 "memory device" | grep speed | sort-N | uniq-C # clock speed
1.3 check related Yum sources
Configure the public Yum source. We recommend that you use the Netease Yum source.
1.4 disable SELinux
1 [[email protected] ~]# vi /etc/sysconfig/selinux 2 SELINUX=disabled
2. Deploying KVM Software
- Libvirt: The virtualization API for operating and managing KVM virtual machines. It is written in C and can be called by python, Ruby, Perl, PHP, Java, and other languages. You can perform operations on hypervisors such as KVM, VMWare, xen, hyper-V, and lxc.
- Virsh: libvirt-based command line tool (CLI)
- Virt-Manager: libvirt-based GUI tool
- Virt-v2v: VM format migration tool
- Virt-* tool: Includes virt-install (command line tool for creating KVM virtual machines), virt-Viewer (tool for connecting to the screen of virtual machines), virt-clone (Virtual Machine cloning tool ), virt-top, etc.
- Svirt: security tools
2.1 install KVM in yum
1 [[email protected] ~] # Yum-y install qemu-KVM libvirt-Python libguestfs-tools virt-install virt-Manager 2 [[email protected] ~] # Lsmod | grep KVM # verify whether the KVM module has added 3 kvm_intel 162153 0 4 KVM 525259 1 kvm_intel # configure soft connections for ease of management.
2.2 set libmongod service to self-start
1 [[email protected] ~] # Systemctl enable libvirtd 2 [[email protected] ~] # Systemctl start libvirtd 3 [[email protected] ~] # Virsh-C qemu: // system list # view the virtual machine environment (virsh list -- all) 4 ID name state 5 ------------------------------------------------ 6 [[email protected] ~] # Ln-S/usr/libexec/qemu-KVM/usr/bin/qemu-KVM
2.3 create a virtual machine directory
1 [[email protected] ~] # Mkdir-P/data/images # store the KVM Virtual Machine directory 2 [[email protected] ~] # Mkdir-P/data/ISO # store the ISO image directory
3. Configure the bridge 3.1 to add a virtual bridge
1 [[email protected] ~] # Vi/etc/sysconfig/network-scripts/ifcfg-eth0 2 name = eth0 3 device = eth0 4 onboot = Yes 5 Bridge = br0 6 [[email protected] ~] # Vi/etc/sysconfig/network-scripts/ifcfg-br0 7 type = "bridge" 8 bootproto = static 9 device = "br0" 10 onboot = "yes" 11 dns1 = 223.5.5 12 ipaddr = 172.24.8.32 13 prefix = 24 14 gateway = 172.24.8.2 15 delay = "0" 16 [[email protected] ~] # Vi/etc/sysctl. conf # modify sysctl. conf 17 Net. ipv4.ip _ forward = 1 18 [[email protected] ~] # Sysctl-P/etc/sysctl. conf 19 [[email protected] ~] # Systemctl restart Network # restart the NIC Service
3.2 view Bridges
1 [[email protected] ~]# brctl show 2 bridge name bridge id STP enabled interfaces 3 br0 8000.000c29dd8149 no eth0 4 virbr0 8000.525400a5f00a yes virbr0-nic
002. KVM environment deployment