傳統數據中心面臨的問題:php
雲計算node
雲計算的分類linux
雲計算的分層:ios
QEMU建立虛擬機vim
[root@linux-node1 ~]# grep -E "(vmx|svm)" /proc/cpuinfo #檢查cpu是否支持vmx或者svm flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc pni pclmulqdq vmx ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer xsave avx hypervisor lahf_lm tpr_shadow vnmi ept vpid tsc_adjust arat
[root@linux-node1 ~]# yum -y install qemu-kvm qemu-kvm-tools libvirt(管理虛擬機的工具) [root@linux-node1 ~]# yum -y install virt-install(安裝虛擬機用的)
[root@linux-node1 ~]# systemctl enable libvirtd [root@linux-node1 ~]# systemctl start libvirtd [root@linux-node1 ~]# ifconfig virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255 ether 52:54:00:79:0d:48 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
虛擬機安裝的需求windows
[root@linux-node1 ~]# qemu-img create -f raw /opt/CentOS-7-x86_64.raw 10G # -f:指定格式,建立一個10G的CentOS-7-x86_64.raw的虛擬機磁盤 [root@linux-node1 ~]# virt-install --virt-type kvm --name CentOS7-x86_64 --ram 1024 --cdrom=/opt/CentOS-7-x86_64-Minimal-1708.iso --disk path=/opt/CentOS-7-x86_64.raw --network=default --graphics vnc,listen=0.0.0.0 --noautoconsole #建立虛擬機
[](http://www.tightvnc.com/downl...
鏈接ip是虛擬機的ipnet.ifnames(不是kvm的),而後按下tab按鍵,輸入net.ifnames=0 biosdevname=0
(這樣便於網卡管理)
正常開始安裝centos
[root@linux-node1 ~]# virsh list --all Id Name State ---------------------------------------------------- 1 CentOS7-x86_64 running
[root@linux-node1 ~]# virsh start CentOS7-x86_64 [root@linux-node1 ~]# virsh shutdown CentOS7-x86_64
須要確認KVM虛擬機的網卡是否開啓api
ps -ef | grep kvm
管理虛擬化進程,若是這個進程掛了的話,不影響KVM虛擬機的進程,只是影響管理。安全
[root@linux-node1 ~]# cd /etc/libvirt/qemu #管理地址 [root@linux-node1 qemu]# ls CentOS7-x86_64.xml networks [root@linux-node1 qemu]# vim CentOS7-x86_64.xml # 不能直接vim修改, [root@linux-node1 qemu]# virsh edit CentOS7-x86_64 #管理KVM,可是openstack就不能這麼搞了
宿主機和虛擬機都要是(centos7以上的系統):支持熱添加CPU和內存服務器
[root@linux-node1 qemu]# virsh edit CentOS7-x86_64 <vcpu placement='static'>1</vcpu> # 改爲: <vcpu placement='auto' current="1">4</vcpu> #表明當前是1,最大是4(前提須要保證宿主機的cpu個數和虛擬機一致) [root@linux-node1 qemu]# virsh setvcpus CentOS7-x86_64 2 --live #這樣就能夠了
[root@linux-node1 ~]# virsh --help | grep monitor qemu-monitor-command QEMU Monitor Command qemu-monitor-event QEMU Monitor Events [root@linux-node1 ~]# virsh qemu-monitor-command CentOS7-x86_64 --hmp --cmd info balloon #查看虛擬機內存 balloon: actual=1024 [root@linux-node1 ~]# virsh qemu-monitor-command CentOS7-x86_64 --hmp --cmd balloon 512 #熱修改內存 [root@linux-node1 ~]# virsh qemu-monitor-command CentOS7-x86_64 --hmp --cmd info balloon balloon: actual=512
[root@linux-node1 ~]# brctl show bridge name bridge id STP enabled interfaces virbr0 8000.525400790d48 yes virbr0-nic vnet0 [root@linux-node1 ~]# brctl addbr br0 #建立橋接網卡 [root@linux-node1 ~]# brctl addif br0 ens32 #橋接到宿主機(會斷網,建議用腳本) # 此時斷網了,就要手動上到宿主機執行 [root@linux-node1 ~]# ip addr del dev ens32 192.168.56.11/24 # 刪除宿主機IP配置 [root@linux-node1 ~]# ifconfig br0 192.168.56.11/24 up # 橋接網絡設置爲出口 [root@linux-node1 ~]# route add default gw 192.168.56.2 # 添加網關 ping qq.com
[root@linux-node1 ~]# virsh edit CentOS7-x86_64 <interface type='network'> <mac address='52:54:00:71:c9:f9'/> <source network='default'/> 改成: <interface type='bridge'> <mac address='52:54:00:71:c9:f9'/> <source bridge='br0'/>