当前位置:首页 » 操作系统 » 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 浏览:763
如何提高三星a7安卓版本 发布:2024-09-20 08:42:35 浏览:662
如何更换服务器网站 发布:2024-09-20 08:42:34 浏览:309
子弹算法 发布:2024-09-20 08:41:55 浏览:287
手机版网易我的世界服务器推荐 发布:2024-09-20 08:41:52 浏览:815
安卓x7怎么边打游戏边看视频 发布:2024-09-20 08:41:52 浏览:160
sql数据库安全 发布:2024-09-20 08:31:32 浏览:91
苹果连接id服务器出错是怎么回事 发布:2024-09-20 08:01:07 浏览:505
编程键是什么 发布:2024-09-20 07:52:47 浏览:655
学考密码重置要求的证件是什么 发布:2024-09-20 07:19:46 浏览:479