最近應公司業務需求,在乙個配置比較高的虛擬機器上部署kvm,分一些虛擬機器出來。怕過一些坑,記錄一下。之前我只在centos桌面環境下用過,滑鼠點點。現在在虛擬機器上部署,找了不少資料
1部署kvm
yum install qemu-kvm qemu-img \
virt-manager libvirt libvirt-python virt-manager \
libvirt-client virt-install virt-viewer -y
systemctl start libvirtd
檢視命令virsh list --all可以使用了
2宿主機網橋設定,不設定的話,會隨機生成乙個網橋,導致虛擬網絡卡被錯誤繫結到其他網橋上
在有真實ip的網絡卡上配置,去掉ip以及最後指定網橋即可
type="ethernet"
bootproto="none"
defroute="yes"
peerdns="yes"
peerroutes="yes"
ipv4_failure_fatal="no"
ipv6init="yes"
ipv6_autoconf="yes"
ipv6_defroute="yes"
ipv6_peerdns="yes"
ipv6_peerroutes="yes"
ipv6_failure_fatal="no"
ipv6_addr_gen_mode="stable-privacy"
name="eth0"
device="eth0"
onboot="yes"
bridge=br0
[root@dmstest network-scripts]# cat ifcfg-br0
type=bridge
#proxy_method=none
#browser_only=no
bootproto=static
#defroute=yes
#ipv4_failure_fatal=no
#ipv6init=yes
#ipv6_autoconf=yes
#ipv6_defroute=yes
#ipv6_failure_fatal=no
#ipv6_addr_gen_mode=stable-privacy
#name=em4
#uuid=6602252d-b8b5-46d2-b997-f840c8041215
device=br0
onboot=yes
ipaddr=172.20.69.199
netmask=255.255.255.0
gateway=172.20.69.1
dns1=10.0.12.210
dns2=172.20.70.100
systemctl restart network
3新建虛擬機器
centos
qemu-img create -f qcow2 vm1-disk1.qcow2 10g
virt-install \
--name=vm2 \
--disk path=/home/vm2-disk1.qcow2 \
--vcpus=4 --ram=8096 \
--cdrom=/root/centos-7-x86_64-minimal-2003.iso \
--network network=default \
--graphics vnc,listen=0.0.0.0,,port=5910 \
--os-type=linux \
--os-variant=rhel7
windows2008 r2
qemu-img create -f qcow2 vm1-disk1.qcow2 150g
virt-install \
--name=vm1 \
--disk path=/home/vm1-disk1.qcow2 \
--vcpus=4 --ram=8096 \
--cdrom=/root/cn_windows_server_2008_r2_standard_enterprise_datacenter_web_x64_***_x15-50360.iso \
--network network=default \
--graphics vnc,listen=0.0.0.0,,port=5911 \
--os-type=windows
5宿主機上繫結網絡卡
brctl addif brx vnety
虛擬網絡卡新增到網橋所在br0
最後遇到了2個問題,其中是1個是虛擬機器建立時沒有許可權
坑1virt-install \
> --name=vm1 \
> --disk path=/home/vm1-disk1.qcow2 \
> --vcpus=1 --ram=1024 \
> --cdrom=/root/centos-7-x86_64-minimal-2003.iso \
> --network network=default \
> --graphics vnc,listen=0.0.0.0 \
> --os-type=linux \
> --os-variant=rhel7
warning graphics requested but display is not set. not running virt-viewer.
warning no console to launch for the guest, defaulting to --wait -1
引用了這個大佬的解決方法處理
坑2就是虛擬機器建立了閘道器不通,找了一圈基本都是網橋沒有繫結
第二步配置了網橋之後
brctl addif brx vnety
虛擬網絡卡新增到網橋所在br0即可
如果虛擬網絡卡已經繫結了其他網橋使用brctl delif brx vnety即可
Gui Bash命令列模式
1 mkdir filename 2 cd dirpath 3 git init 4 git clone d x 本地 git clone git github.com fsliurujie test.git ssh協議 git clone git git協議 git clone https htt...
KVM虛擬機器 裝系統 命令列
一般在建立虛擬機器前,如果需要橋接虛擬機器,就需要建立橋接網口,具體看自己的需求。建立乙個虛擬機器,可以通過virt manager來完成,圖形化介面,但是這個功能不全,不能隨心所欲,例如,需要將虛擬機器建立在不同的位置上,畢竟,預設的儲存是在 var lib libvirt images下,無法進...
命令列模式和互動模式
1,有 標記的是互動模式,直接運算,輸入exit 可退出互動模式。在互動模式的提示符 下,直接輸入 按回車,就可以立刻得到 執行結果。如 100 200 300 3 3 3 27 3 3 27 10 3 3.3333333333333335 為取餘數 10 3 1 round 1.123 1 rou...