我有几年在命令行上使用 Linux 的经验,但这是我第一次尝试使用 GUI 来设置它。
我使用的是 CentOS 7(64 位),并且运行了以下命令:
yum groupinstall "X Window System" "Desktop"
yum install tigervnc-server xorg-x11-fonts-Type1
vncpasswd
使用这些命令安装东西(我认为是 VNC 服务器和 Gnome)后,我在以下位置创建了这个文件/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" &
startx &
exec gnome-session &
然后我尝试用以下命令启动 vnc 服务器:vncserver
。这打印出来:
New '<VM-Name>:1 (root)' desktop is <VM-Name>:1
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/<VM-Name>:1.log
我在本地计算机(Windows 7,64 位)上启动了 VNC Viewer 并连接到虚拟机,但我看到的只是深灰色背景,左上角有 3 个关于剪贴板的复选框。我得到的光标是一个 X。
我在键盘上按的任何东西似乎都没有任何作用。
VNC 方面的一切似乎都很好,但我希望有某种桌面,我可以从中浏览我的文件系统……或者使用此虚拟机以图形方式执行任何操作的其他方式。
看起来它一定找不到我的窗口或桌面管理器或其他东西(我的术语可能有问题 - 如果是,请纠正我) - 但我的脚本说启动 gnome,并且 VNC 日志没有表明任何问题,所以除了灰色矩形之外,我不应该看到其他东西吗?
既然我提到过,下面是我的 VNC 日志 ( ) 中的内容/root/.vnc/<VM-Name>:1.log
:
Xvnc TigerVNC 1.2.80 - built Jun 10 2014 06:14:52
Copyright (C) 1999-2011 TigerVNC Team and many others (see README.txt)
See http://www.tigervnc.org for information on TigerVNC.
Underlying X server release 11500000, The X.Org Foundation
Initializing built-in extension Generic Event Extension
Initializing built-in extension SHAPE
Initializing built-in extension MIT-SHM
Initializing built-in extension XInputExtension
Initializing built-in extension XTEST
Initializing built-in extension BIG-REQUESTS
Initializing built-in extension SYNC
Initializing built-in extension XKEYBOARD
Initializing built-in extension XC-MISC
Initializing built-in extension XFIXES
Initializing built-in extension RENDER
Initializing built-in extension RANDR
Initializing built-in extension COMPOSITE
Initializing built-in extension DAMAGE
Initializing built-in extension MIT-SCREEN-SAVER
Initializing built-in extension DOUBLE-BUFFER
Initializing built-in extension RECORD
Initializing built-in extension DPMS
Initializing built-in extension X-Resource
Initializing built-in extension XVideo
Initializing built-in extension XVideo-MotionCompensation
Initializing built-in extension VNC-EXTENSION
Initializing built-in extension GLX
Wed Sep 30 13:10:31 2015
vncext: VNC extension running!
vncext: Listening for VNC connections on all interface(s), port 5901
vncext: created VNC server for screen 0
Wed Sep 30 13:10:47 2015
Connections: accepted: <my ip>::47407
SConnection: Client needs protocol version 3.8
SConnection: Client requests security type VncAuth(2)
Wed Sep 30 13:11:02 2015
VNCSConnST: Server default pixel format depth 24 (32bpp) little-endian rgb888
VNCSConnST: Client pixel format depth 8 (8bpp) color-map
Wed Sep 30 14:27:49 2015
Connections: closed: <my ip>::47407 (Clean disconnection)
SMsgWriter: framebuffer updates 3
SMsgWriter: raw rects 1, bytes 16396
SMsgWriter: ZRLE rects 1, bytes 802
SMsgWriter: raw bytes equivalent 802840, compression ratio 46.682172
这里没有任何内容向我表明任何错误。我应该在其他地方检查另一个日志文件吗?我是否应该以某种方式进入某些内容的调试模式(什么/如何?)我的脚本中是否缺少某些内容(顺便说一下,xstartup
它是可执行的)。+x
一切工作正常吗?我只需要发送一些组合键即可获得除空白灰色屏幕之外的屏幕?有什么我应该寻找的东西,netstat
或者ps
可以告诉我事情是否有效?
编辑:在对我的 xstartup 文件进行 roaima 建议的更改并重新启动 VNC 后,这是我在日志文件中得到的输出:
Xvnc TigerVNC 1.2.80 - built Jun 10 2014 06:14:52
Copyright (C) 1999-2011 TigerVNC Team and many others (see README.txt)
See http://www.tigervnc.org for information on TigerVNC.
Underlying X server release 11500000, The X.Org Foundation
Initializing built-in extension Generic Event Extension
Initializing built-in extension SHAPE
Initializing built-in extension MIT-SHM
Initializing built-in extension XInputExtension
Initializing built-in extension XTEST
Initializing built-in extension BIG-REQUESTS
Initializing built-in extension SYNC
Initializing built-in extension XKEYBOARD
Initializing built-in extension XC-MISC
Initializing built-in extension XFIXES
Initializing built-in extension RENDER
Initializing built-in extension RANDR
Initializing built-in extension COMPOSITE
Initializing built-in extension DAMAGE
Initializing built-in extension MIT-SCREEN-SAVER
Initializing built-in extension DOUBLE-BUFFER
Initializing built-in extension RECORD
Initializing built-in extension DPMS
Initializing built-in extension X-Resource
Initializing built-in extension XVideo
Initializing built-in extension XVideo-MotionCompensation
Initializing built-in extension VNC-EXTENSION
Initializing built-in extension GLX
Thu Oct 1 12:01:36 2015
vncext: VNC extension running!
vncext: Listening for VNC connections on all interface(s), port 5901
vncext: created VNC server for screen 0
/root/.vnc/xstartup: line 8: gnome-session: command not found
/root/.vnc/xstartup: line 6: xterm: command not found
xauth: file /root/.serverauth.2286 does not exist
X.Org X Server 1.15.0
Release Date: 2013-12-27
X Protocol Version 11, Revision 0
Build Operating System: 2.6.32-220.17.1.el6.x86_64
Current Operating System: Linux InteractSL-TaylorCognosTest 3.10.0-229.7.2.el7.x86_64 #1 SMP Tue Jun 23 22:06:11 UTC 2015 x86_64
Kernel command line: BOOT_IMAGE=/vmlinuz-3.10.0-229.7.2.el7.x86_64 root=UUID=9bdbb9b7-a256-4676-8449-34b054b2950a ro vconsole.keymap=us crashkernel=auto vconsole.font=latarcyrheb-sun16 LANG=en_US.UTF-8
Build Date: 10 April 2015 11:44:42AM
Build ID: xorg-x11-server 1.15.0-33.el7_1
Current version of pixman: 0.32.4
Before reporting problems, check http://wiki.x.org
to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
(++) from command line, (!!) notice, (II) informational,
(WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/var/log/Xorg.0.log", Time: Thu Oct 1 12:01:39 2015
(==) Using config directory: "/etc/X11/xorg.conf.d"
(==) Using system config directory "/usr/share/X11/xorg.conf.d"
Initializing built-in extension Generic Event Extension
Initializing built-in extension SHAPE
Initializing built-in extension MIT-SHM
Initializing built-in extension XInputExtension
Initializing built-in extension XTEST
Initializing built-in extension BIG-REQUESTS
Initializing built-in extension SYNC
Initializing built-in extension XKEYBOARD
Initializing built-in extension XC-MISC
Initializing built-in extension XINERAMA
Initializing built-in extension XFIXES
Initializing built-in extension RENDER
Initializing built-in extension RANDR
Initializing built-in extension COMPOSITE
Initializing built-in extension DAMAGE
Initializing built-in extension MIT-SCREEN-SAVER
Initializing built-in extension DOUBLE-BUFFER
Initializing built-in extension RECORD
Initializing built-in extension DPMS
Initializing built-in extension Present
Initializing built-in extension X-Resource
Initializing built-in extension XVideo
Initializing built-in extension XVideo-MotionCompensation
Initializing built-in extension SELinux
Initializing built-in extension XFree86-VidModeExtension
Initializing built-in extension XFree86-DGA
Initializing built-in extension XFree86-DRI
Initializing built-in extension DRI2
Loading extension GLX
xinit: connection to X server lost
^M
waiting for X server to shut down
Thu Oct 1 12:01:39 2015
Connections: accepted: 129.42.208.178::30139
Thu Oct 1 12:01:40 2015
SConnection: Client needs protocol version 3.8
SConnection: Client requests security type VncAuth(2)
error setting MTRR (base = 0xf0000000, size = 0x00400000, type = 1) Invalid argument (22)
(EE) Server terminated successfully (0). Closing log file.
Thu Oct 1 12:01:41 2015
VNCSConnST: Server default pixel format depth 24 (32bpp) little-endian rgb888
VNCSConnST: Client pixel format depth 8 (8bpp) color-map
Thu Oct 1 12:05:11 2015
Connections: closed: 129.42.208.178::30139 (Clean disconnection)
SMsgWriter: framebuffer updates 3
SMsgWriter: raw rects 1, bytes 16396
SMsgWriter: ZRLE rects 1, bytes 773
SMsgWriter: raw bytes equivalent 802840, compression ratio 46.761023
答案1
(这必须是一个增量答案,因为现在有太多评论。)
VNC 的灰色(可能是点状)背景是典型的未运行 X Display Server 的背景。
你的/root/.vnc/xstartup
样子很奇怪。
线路
exec
通过控制永久到指定为其参数的文件,因此仅执行脚本的前两行非注释行。值得查看参考文献xinitrc
以了解它想要做什么。 (如果文件不太长,请将其添加到问题中。)exec
后面跟着的并不常见,&
因为它否定了 的含义exec
。
根据评论中的信息,我们还需要修复PATH
.因此,生成的xstartup
代码如下所示:
#!/bin/sh
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
您记得使该文件可执行吗?chmod u+x /root/.vnc/xstartup
如果这仍然不起作用,请再次注释前两行,或将文件更新为如下所示:
#!/bin/sh
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
startx &
gnome-session &
答案2
我有类似的问题。 VNC启动,可以连接,但桌面空。 Oracle Linux 7.2(与 RHEL7.2 几乎是 1:1)
没有错误等
我检查了执行的命令/etc/X11/xinit/xinitrc
,发现/usr/bin/twm
系统中不存在默认(!!!)窗口管理器文件(尽管选择了“带 GUI 的服务器”作为安装选项)。
简单修复:先备份
cp -p /etc/X11/xinit/xinitrc /etc/X11/xinit/xinitrc.orig
然后
# Change in /etc/X11/xinit/xinitrc:
from:
# [ -x /usr/bin/twm ] && /usr/bin/twm
to:
# [ -x /usr/bin/mwm ] && /usr/bin/mwm
希望您的系统中存在 mwm 文件,就像我的情况一样。