problems with traditional data centers:Low resource utilization, poor automation of resource allocation
Introduction to Cloud computing:Cloud computing is a sort of
pay-per-use mode, this mode provides the available, convenient, on-demand
Network Access, enter a configurable calculation
resource Sharing Pool(resources include networks, servers, storage, applications, services) that can be delivered quickly, with little or no management effort, or with minimal interaction with service providers. How many ports does tomcat provide? Full virtualization: Direct use of the underlying hardware such as: KVM semi-virtualized: Using a middleware to invoke the underlying hardware For example: Xen hardware virtualization: Software Virtualization: Application Virtualization: A machine running eight Tomcat and running eight VMS running eight TOMCATKVM is a kernel module QEMU is the virtualization installation software for network IO and hard disk IO
[Email protected] ~]# yum-y install QEMU-KVM qemu-kvm-tools virt-manager libvirt virt-install |
Check whether virtualization is supported
[Email protected] ~]# grep-e "(VMX|SVM)"/proc/cpuinfovmx:intersvm:amd[[email protected] ~]# lsmod | grep kvmkvm_intel 148081 0KVM 461126 1 Kvm_intel |
Create a hard disk
[Email protected] ~]# qemu-img create-f raw/opt/centos-7.1-x86_64.raw 10GFormatting '/opt/centos-7.1-x86_64.raw ', FMT =raw size=10737418240 |
Start the LIBVIRTD service
[[email protected] ~]# Systemctl enable Libvirtd.service[[email protected] ~]# systemctl start Libvirtd.service[[email PR Otected] ~]# systemctl status Libvirtd.service |
Disk Copy
[email protected] ~]# DD If=/dev/cdrom of=/opt/centos-7.1.iso |
Set up a virtual machine
[[Email protected] ~] #virt-install--name centos-7.1-x86_64--virt-type KVM--ram 1024x768--cdrom=/opt/centos-7.1.iso-- Disk Path=/opt/centos-7.1-x86_64.raw--network network=default--graphics vnc,listen=0.0.0.0--noautoconsole |
Modify the name of the network card (using the TAB key)
Net.ifnames=0 biosdevname=0 |
Basic operations
Turn off virtual machine Virsh Shudown centos-7.1-x86_64 (hostname) Virsh destroy CENTOS-7.1-X86_64 (hostname) Open virtual machine Virsh start centos-7.1-x86_ 64 Delete virtual machine Virsh undefine centos-7.1-x86_64 view virtual machine (All) virsh list--all edit virtual machine Virsh Editor centos-7.1-x86_64 Hang Virsh suspended Centos-7.1-x86_64 Resume Virsh Resume centos-7.1-x86_64 |
To view the virtual machines that are running:
A KVM virtual machine is a KVM process. Cd/etc/libvirt/qemucpu Hot Add Virsh edit hostname set here the maximum is 4 <vcpu placement= ' auto ' current= "1" >4</vcpu> Virsh SHUTD own hostname Virsh start hostname hot Add, add two Cpuvirsh Setvcpus host name 2--live network configuration
Just boot the virtual machine's Nic, and his KVM machine will start a DHCP server. [[Email protected] network-scripts]# PS aux|grep dnsnobody 2248 0.0 0.0 15524 880? S 14:07 0:00/sbin/dnsmasq--conf-file=/var/lib/libvirt/dnsmasq/default.conf--dhcp-script=/usr/libexec/libvirt_ Leaseshelper exists inside this cat/var/lib/libvirt/dnsmasq/default.confstrict-orderpid-file=/var/run/libvirt/network/ Default.pidexcept-interface=lobind-dynamicinterface=virbr0dhcp-range=192.168.122.2,192.168.122.254 dhcp-no-overridedhcp-leasefile=/var/lib/libvirt/dnsmasq/default.leasesdhcp-lease-max=253dhcp-hostsfile=/var/ Lib/libvirt/dnsmasq/default.hostsfileaddn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts Press Ifconfig Tool yum-y Install Net-tools |
CPU Hot Add (can only be CentOS7)To implement a CPU hot add, you must first set the total number of CPUs, and the total number of hot additions cannot exceed the combined number of CPUs. Method One: Modify the XML file
[Email protected] network-scripts]# Virsh edit centos-7.1-1-x86_64 Original: <vcpu placement= ' static ' >1</vcpu> now: <vcpu placement= ' auto ' current= ' 1 ' >4</vcpu> vcpus match mode is automatic, current is 1, max is 4 need reboot to implement view Cat/proc/cpuinfo in virtual machine |grep "Processor" |wc-l1 in KVM Cpuvirsh setvcpus centos-7.1-x86_64 2--live if not, you need to place the above o 1virsh setvcpus centos-7.1-x86_ 3--live Hot Add can only be added, can not be reduced. (Boot status) |
Mode two: At the time of installation
[[email protected] network-scripts]# virt-install--help |grep CPU--vcpus vcpus number of Vcpus to Configu Re for your guest. Ex:--vcpus 5--vcpus 5,maxcpus=10,cpuset=1-4,6,8--v CPUs sockets=2,cores=4,threads=2, |
memory thermal expansion and compression, total cannot exceed maximum memory
[[email protected] network-scripts]# virsh Edit centos-7.1-1-x86_ 64 Max Memory <memory unit= ' KiB ' >4048576</memory> current memory <currentmemory unit= ' KiB ' >1048576</ Currentmemory> |
View Virsh qemu-monitor-command centos-7.1-x86_64--HMP--cmd info balloon settings Virsh Qemu-monitor-command centos-7.1-x86_64--hmp--cmd Balloon 600 #硬盘: Full mirror mode sparse mode raw qcow2qemu-img [[email protected] opt]# brctl addbr br0[[email protected] opt]# brctl show[[email protected] ~]# brctl addif br0 eth0 && ip addr del dev eth0 10.0.0.111/24 && ifconfig br0 10.0.0.111 /24 up && route add default GW 10.0.0.2 && iptables-f http://www.unixhot.com/ Article/4 [[email protected] ~]# brctl ADDBR br0[[email Protected] ~]# brctl Show bridge name Bridge id STP enabled interfacesbr0 8000.000000000000 novirbr0 8000.525400035327 yes virbr0-nic[[email protected] ~]# brctl addif br0 eth0 [[email protected] ~]# ip addr del dev 10.0.0.100/24[[email protected] ~]# ifconfig br0 10.0.0.100/24 up shut down firewall systemctl stop Firewalld.servicesystemctl Disable Firewalld.service View selinuxgetsebool full virtualization Semi-virtualized the original implementation of: Virtual Memory ===> virtual machine physical memory host virtual memory ===> host physical memory now implemented: EPT (inter) Virtual machine's virtual memory = = =Optimized memory addressing of =ept===== host's physical Memory: EPT Memory Merge: KSM large-page memory: khugepaged merges continuous 4K memory into 2 m-memory consolidation [[email protected] ~]# PS aux |grep ksmdroot 280 0.0 0.0 0 0? sn 20:37 0:00 [KSMD] Large page memory [[email protected] ~]# cat/sys/kernel/mm/transparent_hugepage/enabled[always] madvise never[[email protected] ~]# PS aux |grep khugepagedroot 281 0.0 0.0 0 0? sn 20:37 0:02 [khugepaged] i/o optimization: Virtio semi-virtualized I/O scheduling algorithm: There are three defaults on CentOS7: NoOp deadline Cfq[[email protected] ~]# dmesg |grep scheduler[ 1.385817] IO scheduler noop registered[ 1.385820] IO Scheduler deadline registered (default) [ 1.385851] IO scheDuler CFQ registered default is deadline[[email protected] ~]# cat/sys/block/sda/queue/schedulernoop [deadline] CFQ modified to cfg[[email protected] ~]# echo CFQ >/sys/block/sda/queue/scheduler [[email protected] ~]# Cat/sys/block/sda/queue/scheduler noop deadline [CFQ] Permanent modification: Change kernel parameters [[email] protected] ~]# elevator=noopssd words, must be changed to NoOp, so performance is the best.
Concept Links:What is restapihttp://www.ruanyifeng.com/blog/2014/05/restful_api.html what is soahttp://baike.baidu.com/subview/21305/ 5033544.htm what is Message Queuing http://baike.baidu.com/view/262473.htm what is Object storage http://www.zhihu.com/question/21536660
deployment, application, tuning of virtualized KVM