當前位置:首頁 » 操作系統 » kvmlinux

kvmlinux

發布時間: 2022-01-08 20:22:01

1. linux里的KVM

http://sourceforge.net/projects/kvm/files/qemu-kvm/0.14.0/qemu-kvm-0.14.0.tar.gz/download?_test=goal

2. LINUX的XEN和KVM到底區別在什麼地方

目前為止,虛擬技術的老大仍然是VMware,雖然被EMC收購,名義上是EMC的老二,但事實上由於技術的牛X,老二不是很擺老大,當然這只是聊天的話,不做為事實依據。

一、KVM簡介

KVM是一個全虛擬化的解決方案。可以在x86架構的計算機上實現虛擬化功能。但KVM需要CPU中虛擬化功能的支持,只可在具有虛擬化支持的CPU上運行,即具有VT功能的Intel CPU和具有AMD-V功能的AMD CPU。

Xen與KVM的比較

Xen是Linux下的一個虛擬化解決方案,但由於被Citrix收購後,變成了和紅帽企業版一樣了,賣服務收取費用,Redhat從rhel6.0開始已經從內核中把XEN踢出去了,全心投入開發免費的KVM,雖然市場上老用戶還在用Xen,但相信kvm會逐步佔領大面積的市場,必竟有redhat做為強大支持源。

Xen的實現方法是運行支持Xen功能的kernel,這個kernel是工作在Xen的控制之下,叫做Domain0,使用這個kernel啟動機器後,你可以在這個機器上使用qemu軟體,虛擬出多個系統。Xen的缺點是如果你需要更新Xen的版本,你需要重新編譯整個內核,而且,稍有設置不慎,系統就無法啟動。

相比較,KVM就簡化的多了。它不需要重新編譯內核,也不需要對當前kernel做任何修改,它只是幾個可以動態載入的.ko模塊。它結構更加精簡、代碼量更小。所以,出錯的可能性更小。並且在某些方面,性能比Xen更勝一籌。

二、KVM的使用

現在以Turbolinux 11版本為基礎,介紹KVM的使用方法。

在安裝之前,你需要先確認,你的CPU是否支持虛擬化技術,執行:

# egrep '^flags.*(vmx|svm)' /proc/cpuinfo

如果有輸出返回,則表示你的CPU支持虛擬化技術。

1.KVM的安裝

從官方網站下載KVM源碼包:http://kvm.qumranet.com
我們使用KVM-33版本

# tar zxf kvm-33.tar.gz
# cd kvm-33
# ./configure --prefix=/usr/local/kvm-33
# make
# make install

make install後,kvm的模塊會安裝到/lib/moles/$KernelVersion/extra/目錄下。其他相關文件會安裝到/usr/local/kvm-33/目錄下。

將kvm相關目錄連接到系統目錄中

# ln -s /usr/local/kvm-33/bin/* /usr/bin/
# ln -s /usr/local/kvm-33/lib/* /usr/lib/
(若為x86_64系統,則執行: ln -s /usr/local/kvm-33/lib64/* /usr/lib64/)
# ln -s /usr/local/kvm-33/include/kvmctl.h /usr/include/
# ln -s /usr/local/kvm-33/include/linux/* /usr/include/linux/
# ln -s /usr/local/kvm-33/share/qemu /usr/share/

2.KVM的使用

a.你需要先建立一個映像文件作為虛擬系統的硬碟

# mkdir /images
# cd /images
# /usr/bin/qemu-img -f qcow gtes11.img 20G

b.創建網路配置腳本

# echo 』/sbin/ifconfig $1 10.0.1.1 netmask 255.255.255.0』 > /etc/qemu-ifup

c.載入KVM模塊

Intel CPU使用:
# modprobe kvm-intel
AMD CPU使用:
# modprobe kvm-amd

d.安裝虛擬系統

# /usr/bin/qemu-i386 -m 512 -k en-us -M pc -hda /images/gtes11.img -cdrom /iso/zuma-SP3-rc3-6-\
disc1-20061031.iso -net nic,vlan=1,model=rtl8139,macaddr=00:00:00:00:99:01 -net tap,vlan=1,ifname=tap0,\
script=/etc/qemu-ifup -vnc localhost:1 -boot d

在另一個終端執行:

# vncviewer localhost:1

參數分析:

我們為虛擬系統分配512MB內存。使用gtes11.img作為它的第一塊硬碟,使用Turbolinux10.5的disc1作為它的光碟。
並從光碟引導。它有一塊rtl8139的網卡,MAC地址為:00:00:00:00:99:01,並把這個網卡與主機的tap0介面連接。
tap0介面使用/etc/qemu-ifup腳本進行初始化。虛擬系統的輸出作為一個vnc伺服器,綁定在主機的localhost:1上。

註:

1.若為x86_64系統,則使用/usr/bin/qemu-system-x86_64代替qemu-i386

2.在64位系統上,可以安裝32位和64位的虛擬系統。但在32位系統上,只能安裝32位的虛擬系統。

qemu參數介紹:

-da 映像文件:使用映像文件作為虛擬系統的第一塊硬碟。同樣還可以使用hdb、hdc、hdd指定第2、3、4塊硬碟。
-drom 光碟映像文件:使用光碟映像文件作為虛擬系統的光碟。
-oot [a|c|d|n]:設置虛擬系統的引導順序。a為軟碟機、c為硬碟、d為光碟機、n為網路。
- 內存大小:設置虛擬系統使用的內存大小,單位為MB。
- 語言:設置虛擬系統鍵盤類型。
-et nic[,vlan=n][,macaddr=addr][,model=type]
建立一個虛擬網卡,並把它連接到VLAN的n埠上。
-net tap[,vlan=n][,fd=h][,ifname=name][,script=file]

把主機的TAP網路介面連接到VLAN的n埠上,並使用script指定的腳本進行初始化。

3. linux系統中一個kvm的虛擬機也哪種方式運行

kvm就是個軟體,可以在命令行執行,也可以在桌面環境找到位置雙擊打開。

4. linux 如何卸載kvm虛擬機。

找到該虛機的文件位置,刪除映像文件和配置文件就可以了

5. VMware和kvm哪個作為linux的虛擬機更好

這個不可能吧 程序正在運行 修改參數恐怕是不能成功的這就像程序還在運行 你要刪除這個程序 必須得結束這個程序的進程 否則程序不能被刪除

6. Linux上虛擬機Xen和KVM哪個更強

KVM需要首先檢查下你的cpu是否支持intel的VT虛擬化,或者amd的SVM 虛擬化技術
XEN則不需要, 從技術上來講 KVM比較先進 也更強 不過XEN已經行之多年, 解決方案等比較成熟
安裝kvm方面 首先
cat /proc/cupinfo 如果在flags現有顯示vt 或者svm.下面的步驟就沒有繼續下去的意義了,否則就是浪費時間

下面的以amd的cpu為例
1,准備你的系統里必須有以下這些包
gcc-3.4 libsdl1.2-dev zlib1g-dev libasound2-dev linux-kernel-headers pkg-config libgnutls-dev(這事debian的包機制,只供其他的發行版參考)
2,切換gcc版本(如果你的gcc版本已經是gcc3.x 就沒有必要繼續了)
cd /usr/bin
sudo mv gcc gcc.bak
sudo ln -s gcc-3.4 gcc
3.下載kvm-realease.tar.gz包
wget http://nchc.dl.sourceforge.net/sourceforge/kvm/kvm-59.tar.gz
4,安裝
tar xzf kvm-59.tar.gz
cd kvm-release
./configure --prefix=/usr/local/kvm
make
sudo make install

sudo /sbin/modprobe kvm-amd

ok 這就裝好了, 用qemu或者virtualbox玩玩吧

7. linux怎樣啟動遠程kvm圖形界面

使用VNC軟體:

Linux下VNC配置詳解,以下配置為配置VNC詳細介紹。並解決了用VNC View登入發現畫面是灰色的問題
1. Linux下VNC的配置
首先在Linux的add/remove applications中的system tools下面安裝VNC-server服務安裝完成後直接輸入vncserver 會出現以下內容:
passwd: //只有這個帳號是第一次運行vncserver,才會要求你輸入連接的密碼。
verify:
New 'server1.linux:4 (demo)' desktop is server1.linux:1
Starting applications specified in /home/.vnc/xstartup
Log file is /home/.vnc/server1.linux:1.log
上面這段話表示起動了一個圖形終端,編號為1,要記住這個編號,等下登錄時需要提供這個編號。第一次啟動VNC一定要先直接輸入vncserver。如果你要停止這個進程,使用命令
vncserver -kill :1
啟動後就可以在客戶端上面輸入IP加剛才提到的那個編號即可登陸機器(xxx.xxx.xxx.xxx:1) 看到一個灰色的Xwindow桌面但上面什麼也沒有
運行過一次VNSERVER後會在HOME目錄下面生成一個.VNC文件夾(在開始啟動的時候可看到該文件夾的位置)註:該目錄為隱藏,可直接輸入路徑進入。修改xstartup文件,去掉unset SESSION_MANAGER 和exec /etc/X11/xinit/xinitrc 前面的注釋符號,將最後一行twm & 改成 gnome-session &
vi /root/.vnc/xstartup
#!/bin/sh
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER //此行注釋去掉
# exec /etc/X11/xinit/xinitrc //此行注釋去掉
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm & //改成 gnome-session &
重新啟動VNCSERVER即可
2、VNC的啟動/停止/重啟
#service vncserver start/stop/restart
關閉具體的vncserver命令:
vncserver -kill :1
vncserver -kill :2
3、設置密碼
#vncpasswd
4、客戶端登陸
在vnc客戶端中輸入:伺服器端IP:1或伺服器端IP:2
5、設置登陸到KDE桌面
註:很多情況下,提示VNC無法連接,或者提示10086錯誤都是沒有修改vncservers文件的問題,所以編輯該文件修改
# VNCSERVERS="1:myusername"
# VNCSERVERARGS[1]="-geometry 800x600"
這兩行問題一般都可以解決。
a.
[root@CentOS ~]# vi /etc/sysconfig/vncservers
# # Uncomment the line below to start a VNC server on display :1 # as my 'myusername' (adjust this to your own). You will also # need to set a VNC password; run 'man vncpasswd' to see how # to do that. # # DO NOT RUN THIS SERVICE if your local area network is # untrusted! For a secure way of using VNC, see # <URL:>.http://www.uk.research.att.com/vnc/sshvnc.html
# VNCSERVERS="1:myusername"
VNCSERVERS="1:root"
# VNCSERVERARGS[1]="-geometry 800x600"
VNCSERVERARGS[1]=」-geometry 800×600 -alwaysshared -depth 24″
-alwaysshared代表允許多用戶同時登錄 -depth代為色深,參數有8,16,24,32。
註:紅色部分就是被修改或增加的部分
b.
[root@centos .vnc]$ vi /root/.vnc/xstartup #!/bin/sh
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources xsetroot -solid grey vncconfig -iconic & xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" & #gnome-session & #set starting GNOME desktop startkde &#kde desktop
#twm &
#Text interface
註:紅色部分就是被修改或增加的部分
c.
重啟VNC即可。
vnc安裝 Oracle:
出現錯誤提示:「Xlib: connection to ":1.0" refused by server」
如下處理:
實用技巧:在Linux下設置xhost方法步驟
source:http://www.knowsky.com/397544.html
第一步:用root登陸linux,啟動vnc服務;
第二步:根據vnc起來的埠,設置export DISPLAY=localhost:1(1表示vnc在第一個tty上啟動的),vnc的啟動信息見附件1;
第三步:執行xhost +,並且提示「access control disabled, clients can connect from any host」才正確。
Linux下的操作日誌如下:
[root@localhost ~]# vncserverNew 'localhost:1 (root)' desktop is localhost:1Starting applications specified in /root/.vnc/xstartupLog file is /root/.vnc/localhost:1.log[root@localhost ~]# export DISPLAY=localhost:1 [root@localhost ~]# xhost +access control disabled, clients can connect from any host
在設置xhost時,出現了unable的問題。
使用上訴方法就可以搞定。
一下為我以root身份登錄的配置文件
[root@PC-223-CE ~]# vi /etc/sysconfig/vncservers
# The VNCSERVERS variable is a list of display:user pairs.
#
# Uncomment the lines below to start a VNC server on display :2
# as my 'myusername' (adjust this to your own). You will also
# need to set a VNC password; run 'man vncpasswd' to see how
# to do that.
#
# DO NOT RUN THIS SERVICE if your local area network is
# untrusted! For a secure way of using VNC, see
# <URL:http://www.uk.research.att.com/vnc/sshvnc.html>.
# VNCSERVERS="2:myusername"
# VNCSERVERARGS[2]="-geometry 800x600"
VNCSERVERS="1:root"
VNCSERVERARGS[1]="-geometry 800x600 -alwaysshared -depth 24"
~
[root@PC-223-CE ~]# vi /root/.vnc/xstartup
#!/bin/sh
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
xrdb $HOME/.Xresources
# [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
# [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
# vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
# twm &
gnome-session &
~
更改完後保存,重新啟動VNC即可
3.多個用戶登錄
linux的VNC可以實現多個用戶同時鏈接.方法如下
su 用戶名
vncserver (這里就是第二個用戶了)
第三個用戶是
su 用戶名
vncserver
添加完後需要在/etc/sysconfig/vncserver裡面添加這個用戶,不然就會出現登錄後都是灰色的
另外還需要 修改用戶目錄下的.vnc/xstartup文件
例:我的電腦上已經有一個root用戶,此時我還需要ocmSUSEr這個用戶可以VNC登錄
[root@linuxidc~]# su ocmsuser
[ocmsuser@linuxidcroot]$ vncserver
You will require a password to access your desktops.
Password:
Verify:
New 'ywei:2 (ocmsuser)' desktop is ywei:2
Creating default startup script /home/ocmsuser/.vnc/xstartup
Starting applications specified in /home/ocmsuser/.vnc/xstartup
Log file is /home/ocmsuser/.vnc/ywei:2.log
[ocmsuser@linuxidcroot]$ su - root
Password:
[root@linuxidc~]# vi /etc/sysconfig/vncservers
The VNCSERVERS variable is a list of display:user pairs.
#
# Uncomment the lines below to start a VNC server on display :2
# as my 'myusername' (adjust this to your own). You will also
# need to set a VNC password; run 'man vncpasswd' to see how
# to do that.
#
# DO NOT RUN THIS SERVICE if your local area network is
# untrusted! For a secure way of using VNC, see
# <URL:http://www.uk.research.att.com/archive/vnc/sshvnc.html>.
# Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.
# Use "-nohttpd" to prevent web-based VNC clients connecting.
# Use "-localhost" to prevent remote VNC clients connecting except when
# doing so through a secure tunnel. See the "-via" option in the
# `man vncviewer' manual page.
VNCSERVERS="1:root"
VNCSERVERARGS[1]="-geometry 1280x800 -alwaysshared -depth 24"
VNCSERVERS="2:ocmsuser"
VNCSERVERARGS[2]="-geometry 1280x800 -alwaysshared -depth 24"
~
[root@linuxidc~]# cat /root/.vnc/xstartup
#!/bin/sh
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm &
[root@linuxidc~]# cat /home/ocmsuser/.vnc/xstartup
#!/bin/sh
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm &
[root@linuxidc~]# cp /home/ocmsuser/.vnc/xstartup /home/ocmsuser/.vnc/xstartup.bak
[root@linuxidc~]# cp /root/.vnc/xstartup /home/ocmsuser/.vnc/xstartup
cp: overwrite `/home/ocmsuser/.vnc/xstartup'? yes
[root@linuxidc~]# service vncserver restart
Shutting down VNC server: 2:ocmsuser [ OK ]
Starting VNC server: 2:ocmsuser
New 'ywei:2 (ocmsuser)' desktop is ywei:2
Starting applications specified in /home/ocmsuser/.vnc/xstartup
Log file is /home/ocmsuser/.vnc/ywei:2.log
[ OK ]

8. kvm 所在的宿主必須是linux桌面環境么

是的,kvm只能運行在linux宿主機上面。他是linux核心的一部分。

9. Linux中如何載入kvm模塊

KVM需要支持VT的CPU,看看你的CPU支持。方法:cat
/proc/cpuinfo
|grep
flags
看看裡面有沒有
VT
(intel的cpu)
AMD的標志我忘了。你找找

熱點內容
現在玩游戲的電腦需要什麼配置 發布:2024-04-20 17:09:57 瀏覽:194
游樂園的密碼一般為多少 發布:2024-04-20 17:09:51 瀏覽:40
興元安卓機怎麼進系統 發布:2024-04-20 17:07:16 瀏覽:805
我的世界伺服器如何放村民 發布:2024-04-20 17:05:35 瀏覽:358
手機反編譯dex 發布:2024-04-20 17:01:01 瀏覽:703
安卓怎麼設置微信拍一拍 發布:2024-04-20 16:44:48 瀏覽:568
三星3熱點密碼怎麼設置 發布:2024-04-20 16:30:52 瀏覽:578
用keil編譯顯示警告warn 發布:2024-04-20 16:27:09 瀏覽:893
訪問在哪兒 發布:2024-04-20 16:20:42 瀏覽:200
安卓手機有什麼可以把聲音改成電音的軟體 發布:2024-04-20 16:19:40 瀏覽:563