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

linuxkvm

發布時間: 2022-01-19 23:28:37

A. 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 ]

B. Linux上的kvm虛擬機有沒有命令行控制的方法

1.看看cpu是否支持kvm
[root@localhost ~]# grep -E -o 'vmx|svm' /proc/cpuinfo
#結果顯示vmx表示支持
2.安裝kvm所需要的軟體包
[root@localhost ~]# yum install kvm kmod-kvm qemu kvm-qemu-img virt-viewer

3.安裝完,檢查模塊是否有載入

[root@localhost ~]#lsmod | grep kvm
kvm_intel 85256 0
kvm 224928 2 ksm.kvm_intel
4.使用命令檢查kvm是否成功安裝

[root@localhost ~]#virsh -c qemu:///system list
Id Name State

C. 在linux上面如何用命令行創建kvm虛擬機

你好,在centos裡面用命令行創建kvm:
virt-install --name=rhel7 --disk path=/mnt/personal-data/SPool1/SVol1.img --graphics spice --vcpu=1 --ram=1024 --location=/run/media/dos/9e6f605a-f502-4e98-826e-e6376caea288/rhel-server-7.0-x86_64-dvd.iso --network bridge=virbr0

詳細的請看以下這篇文章把:http://www.linuxprobe.com/linux-command-management-kvm/

D. LINUX里的KVM

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

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

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

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

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

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

物理環境
內存4G ,CPU4個,動態硬碟120G

KVM:

硬碟測試
瞬間讀取速度
Timing cached reads: 23668 MB in 2.00 seconds = 11858.17 MB/sec
Timing buffered disk reads: 294 MB in 3.02 seconds = 123.37 MB/sec

讀取硬碟1G數據速度
1024000000 bytes (1.0 GB) copied, 87.253 seconds, 11.7 MB/s
寫入硬碟1G數據速度
1024000000 bytes (1.0 GB) copied, 10.5519 seconds, 97.0 MB/s

CPU測試
二級緩存
Cat /proc/cpuinfo
cache size : 32 KB

運行一個shell運算腳本 用時13分鍾
Cpu(s): 5.5%us, 0.6%sy, 0.0%ni, 93.3%id, 0.1%wa, 0.4%hi, 0.1%si, 0.0%st
Cpu(s): 0.1%us, 0.2%sy, 0.0%ni, 98.8%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st

Cpu 使用量在 0.1%~~5.5%,比較均勻的增減;內存和交換分區都比較穩定

內存使用測試
執行一個耗費內存的程序 ,運行時間 3分鍾,立即消耗內存到最大
Mem: 3945756k total, 2854516k used, 1091240k free, 288700k buffers
Swap: 1020088k total, 8k used, 1020080k free, 2278948k cached

Mem: 3945756k total, 3919740k used, 26016k free, 12188k buffers
Swap: 1020088k total, 100k used, 1019988k free, 3645968k cached

Vmware:
瞬間硬碟讀取:
Timing cached reads: 24068 MB in 2.00 seconds = 12058.10 MB/sec
Timing buffered disk reads: 790 MB in 3.00 seconds = 263.06 MB/sec

讀取硬碟1G數據速度
1024000000 bytes (1.0 GB) copied, 70.1827 seconds, 14.6 MB/s
寫入硬碟1G數據速度
1024000000 bytes (1.0 GB) copied, 4.5338 seconds, 226 MB/s

CPU 二級緩存
Cat /proc/cpuinfo

cache size : 8192 KB

運行一個shell運算腳本 用時10分鍾
Cpu(s): 4.9%us, 0.7%sy, 0.0%ni, 94.1%id, 0.1%wa, 0.0%hi, 0.1%si, 0.0%st
Cpu(s): 0.0%us, 0.0%sy, 0.0%ni, 99.7%id, 0.2%wa, 0.0%hi, 0.0%si, 0.0%st

Cpu利用量
Cpu 使用量在 0.1%~~4.9%,有不大的起伏;內存和交換分區都比較穩定

內存使用
執行耗費內存程序,執行時間5分鍾,緩慢消耗內存到最大
Mem: 4044464k total, 2974892k used, 1069572k free, 56892k buffers
Swap: 1020088k total, 16k used, 1020072k free, 2605660k cached

Mem: 4044464k total, 4016472k used, 27992k free, 12296k buffers
Swap: 1020088k total, 116k used, 1019972k free, 3692420k cached

綜上所述:

Kvm 內存使用效率比較高,硬碟的寫入速度很慢,CPU利用量穩定,也比較低
VMware 內存使用效率不高,硬碟讀寫速度很快,CPU利用量高
Kvm與Vmware 整體性能從數據上一次數據上看不出來,多次測試後,vmware就稍微明顯地比RedHat的kvm性能好很多。

但是這比較的僅僅是性能,而在開發過程中,開發工具或者環境的專業性和便捷性更為重要

KVM提供的虛擬化需要硬體的支持,是基於硬體的完全虛擬化。自Linux 2.6.20之後集成在Linux的各個主要發行版中。它使用Linux自身的調度器進行管理,所以相對於Xen,其核心源碼很少。KVM目前已成為學術界的主流VMM之一。

而且KVM是GPL的自由開源軟體,這一點與Linux的相得益彰。所以,基於我個人認為在Linux開發這一塊,KVM相對要專業一些,這個是在實際使用中切身體會到的。

H. 怎樣在linux中打開kvm創建的虛機

virt-install --name=rhel7 --disk path=/mnt/personal-data/SPool1/SVol1.img --graphics spice --vcpu=1 --ram=1024 --location=/run/media/dos/9e6f605a-f502-4e98-826e-e6376caea288/rhel-server-7.0-x86_64-dvd.iso --network bridge=virbr0

I. 在linux mint 中怎麼安裝kvm

KVM虛擬機簡介
第一、看看cpu是否支持kvm
[root@localhost ~]# egrep '(vmx|svm)' --color=always /proc/cpuinfo
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx rdtscp lm constant_tsc nonstop_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 sse4_2 popcnt lahf_lm
[root@localhost ~]# grep -E -o 'vmx|svm' /proc/cpuinfo
vmx
第二步:安裝kvm 所需要的軟體包
1.yum install kvm kmod-kvm qemu kvm-qemu-img virt-viewer virt-manager
或者
yum groupinstall KVM
2.安裝完確認一下是否安裝成功
檢查模塊是否有載入
[root@localhost ~]# lsmod | grep kvm
kvm_intel 85256 0
kvm 224928 2 ksm,kvm_intel
也可以使用命令檢查KVM是否成功安裝
virsh -c qemu:///system list
將會顯示如下結果:
[root@localhost ~]# virsh -c qemu:///system list
Id Name State
----------------------------------
如果在這里顯示的是一個錯誤的信息,說明有些東西出現了問題。
3.安裝橋接管理工具
yum install bridge-utils tunctl
4 安裝gui管理工具yum install virt-manager virt-viewer.
5.修改網卡文件
#cd /etc/sysconfig/network-scripts/
#cp ifcfg-eth1 ifcfg-br0
#vim ifcfg-eth1 如下:
# Broadcom Corporation NetXtreme II BCM5716 Gigabit Ethernet
DEVICE=eth1
#BOOTPROTO=none
HWADDR=84:2b:2b:6e:20:d5
ONBOOT=yes
#NETMASK=255.255.255.0
#IPADDR=192.168.1.187
#GATEWAY=192.168.1.1
TYPE=Ethernet
BRIDGE=br0
Vim ifcfg-br0 如下:
# Broadcom Corporation NetXtreme II BCM5716 Gigabit Ethernet
DEVICE=br0
BOOTPROTO=static
HWADDR=84:2b:2b:6e:20:d5
ONBOOT=yes
NETMASK=255.255.255.0
IPADDR=192.168.1.187
TYPE=Bridge
保存網卡配置 重新啟動網卡
#service network restart
檢查br0 是否成功
[root@localhost network-scripts]# ifconfig
br0 Link encap:Ethernet HWaddr 84:2B:2B:6E:20:D5
inet addr:192.168.1.187 Bcast:192.168.1.255 Mask:255.255.255.0
eth0 Link encap:Ethernet HWaddr 84:2B:2B:6E:20:D4
inet addr:117.79.238.187 Bcast:117.79.238.191 Mask:255.255.255.224
eth1 Link encap:Ethernet HWaddr 84:2B:2B:6E:20:D5
inet6 addr: fe80::862b:2bff:fe6e:20d5/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
vnet0 Link encap:Ethernet HWaddr FE:52:00:3E:41:04
inet6 addr: fe80::fc52:ff:fe3e:4104/64 Scope:Link
中間碰到的問題:
1、[root@benjr ~]# virt-manager
在一開始會看到錯誤信息,跳過。系統預設值為xen的hypervisor,需要手動開啟kvm的Hypervisor
Unable to open a connection to the Xen hypervisor/daemon
Verify that:
- A Xen host kernel was booted
- The Xen service has been started.
這個不用管 直接跳過 其中的原因不明
2、內核不能載入kvm模塊
FATAL: Error inserting kvm_amd (/lib/moles/2.6.18-194.el5/weak-updates/kmod-kvm/kvm-amd.ko): Unknown symbol in mole, or unknown parameter (see dmesg)
解決辦法
查看是否是因為bios中關閉了cpu的虛擬化支持 (如果開啟果斷下一步)
yum update kernel 果斷升級內核,重啟伺服器 解決
lsmod | grep kvm (重啟完我偷著樂 !!!)
[root@localhost ~]# lsmod | grep kvm
kvm_intel 85256 1
kvm 224928 2 ksm,kvm_intel
modprobe kvm (載入kvm模塊)
kvm 安裝虛擬機
圖像化安裝
1.應用程序--à系統工具--à虛擬化管理(或者命令調出 virt-manger)
直接圖形化操作跟vm workstation 差不多
a.新建虛擬機,選擇 new

b.虛擬機命名(最好命名一個跟相關應用有關的)

c.選擇cpu 支持的位數和 hypervisor 模式

d.選擇安裝系統的方式和系統

e.選擇iso文件所在位置

f.image存儲的位置和image 的大小(若有單獨的虛擬化分區,可以選擇第一項,我默認)

g.選擇網卡模式 (橋接模式)

h.設置內存大小 和cpu的個數

i.配置完成,虛擬所有信息

系統就不用再寫了,太墨跡了
2.字元命令創建kvm 虛擬機(懶人沒看。直接用的圖像化配置)
3.Kvm虛擬機上網
1、開啟宿主機的路由轉發功能:
echo 1 > /proc/sys/net/ipv4/ip_forward 或者直接在 /etc/sysctl.conf 中添加 修改 net.ipv4.ip_forward = 1
2、配置宿主機iptables NAT
/sbin/iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -j MASQUERADE
/sbin/iptables –t nat –A POSTROUTING –s 192.168.1.0/24 -o eth0 -j SNAT --to 117.79.238.187
/sbin/iptables save
3、配置虛擬機,設置網卡
到此配置完畢!~~~

J. 怎麼停止linux kvm

yum remove kvm 或者 yum remove kvm* 如果是源碼安裝,先找到目錄後直接刪除就可以了 find / -name kvm // 找到目錄 cd **** //進入目錄 rm -rf *** 如果是rpm安裝 rpm -e kvm 或者 rpm -e kvm*

熱點內容
單片機android 發布:2024-09-20 09:07:24 瀏覽:760
如何提高三星a7安卓版本 發布:2024-09-20 08:42:35 瀏覽:660
如何更換伺服器網站 發布:2024-09-20 08:42:34 瀏覽:306
子彈演算法 發布:2024-09-20 08:41:55 瀏覽:284
手機版網易我的世界伺服器推薦 發布:2024-09-20 08:41:52 瀏覽:812
安卓x7怎麼邊打游戲邊看視頻 發布:2024-09-20 08:41:52 瀏覽:158
sql資料庫安全 發布:2024-09-20 08:31:32 瀏覽:90
蘋果連接id伺服器出錯是怎麼回事 發布:2024-09-20 08:01:07 瀏覽:503
編程鍵是什麼 發布:2024-09-20 07:52:47 瀏覽:655
學考密碼重置要求的證件是什麼 發布:2024-09-20 07:19:46 瀏覽:479