我正在运行带有 Gnome 的 CentOS 7.4,在让 VNC 服务器为客户端提供桌面环境时遇到了问题。我得到的要么是空白的黑屏,要么是带有复选框的文本。它正在为 VNC 运行:
Xvnc TigerVNC 1.8.0 - built Aug 7 2017 01:32:32
如果我使用主目录中提供的 .vnc/xstartup:
#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
exec /etc/X11/xinit/xinitrc
它会提示输入密码,但只显示空白的黑屏。它根本没有任何作用。当我从控制台登录同一个帐户时,它运行正常。
我的 VNC 服务器在现已退役的 CentOS 6 系统上运行,因此我决定从该系统尝试 xstart:
#!/bin/sh
vncconfig -iconic &
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
OS=`uname -s`
if [ $OS = 'Linux' ]; then
case "$WINDOWMANAGER" in
*gnome*)
if [ -e /etc/SuSE-release ]; then
PATH=$PATH:/opt/gnome/bin
export PATH
fi
;;
esac
fi
if [ -x /etc/X11/xinit/xinitrc ]; then
exec /etc/X11/xinit/xinitrc
fi
if [ -f /etc/X11/xinit/xinitrc ]; then
exec sh /etc/X11/xinit/xinitrc
fi
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#twm &
exec gnome-session &
但这会为客户端产生灰屏,并显示以下复选框和文本:
Accept clipboard from viewers
Also set primary selection
Send clipboard to viewers
Send primary selection to viewers
我可以选中和取消选中这些框,但仅此而已。不要获得我根据所见的 CentOS 7 文章和文档编辑的桌面环境:
这是 /etc/systemd/system/vncserver@:1.service 文件:
# The vncserver service unit file
#
# Quick HowTo:
# 1. Copy this file to /etc/systemd/system/[email protected]
# 2. Replace <USER> with the actual user name and edit vncserver
# parameters appropriately
# ("User=<USER>" and "/home/<USER>/.vnc/%H%i.pid")
# 3. Run `systemctl daemon-reload`
# 4. Run `systemctl enable vncserver@:<display>.service`
#
# DO NOT RUN THIS SERVICE if your local area network is
# untrusted! For a secure way of using VNC, you should
# limit connections to the local host and then tunnel from
# the machine you want to view VNC on (host A) to the machine
# whose VNC output you want to view (host B)
#
# [user@hostA ~]$ ssh -v -C -L 590N:localhost:590M hostB
#
# this will open a connection on port 590N of your hostA to hostB's port 590M
# (in fact, it ssh-connects to hostB and then connects to localhost (on hostB).
# See the ssh man page for details on port forwarding)
#
# You can then point a VNC client on hostA at vncdisplay N of localhost and with
# the help of ssh, you end up seeing what hostB makes available on port 590M
#
# Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.
#
# 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.
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=forking
User=justme
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=-/usr/bin/vncserver -kill %i
ExecStart=/usr/bin/vncserver %i
PIDFile=/home/justme/.vnc/%H%i.pid
ExecStop=-/usr/bin/vncserver -kill %i
[Install]
WantedBy=multi-user.target
我查看了日志文件,看到的唯一错误/警告是:
[root@myserver ~]# systemctl status vncserver@:1.service
● vncserver@:1.service - Remote desktop service (VNC)
Loaded: loaded (/etc/systemd/system/vncserver@:1.service; enabled; **vendor preset: disabled**)
Active: inactive (dead) since Wed 2017-10-11 05:04:32 EDT; 21min ago
Process: 2456 ExecStop=/usr/bin/vncserver -kill %i (code=exited, status=0/SUCCESS)
Process: 1410 ExecStart=/usr/bin/vncserver %i (code=exited, status=0/SUCCESS)
Process: 1358 ExecStartPre=/usr/bin/vncserver -kill %i (code=exited, status=2)
Main PID: 1570 (code=exited, status=0/SUCCESS)
Oct 11 05:01:31 myserver vncserver[1358]: Can't find file /home/justme/.vnc/myserver:1.pid
Oct 11 05:01:31 myserver vncserver[1358]: You'll have to kill the Xvnc process manually
Oct 11 05:01:34 myserver vncserver[1410]: New 'myserver:1 (justme)' desktop is myserver:1
Oct 11 05:01:34 myserver vncserver[1410]: Starting applications specified in /home/justme/.vnc/xstartup
Oct 11 05:01:34 myserver vncserver[1410]: Log file is /home/justme/.vnc/myserver:1.log
Oct 11 05:01:34 myserver systemd[1]: Started Remote desktop service (VNC).
Oct 11 05:01:34 myserver gnome-session[1952]: gnome-session-binary[1952]: **WARNING: software acceleration check failed: Child process exited with code 1**
Oct 11 05:01:34 myserver gnome-session-binary[1952]: WARNING: software acceleration check failed: Child process exited with code 1
Oct 11 05:04:32 myserver vncserver[2456]: Killing Xvnc process ID 1570
Oct 11 05:04:32 myserver vncserver[2456]: Xvnc process ID 1570 already killed
我曾尝试更改 xstartup 和 etc/systemd/system/vncserver@:1.service 文件,但除了空白屏幕或带有复选框的屏幕之外,它们都没有产生任何结果。
如果有这方面经验的人对更多故障排除有建议,或者您能够发现问题所在,请贡献您的想法。
答案1
按照以下说明操作后https://www.linuxtechi.com/install-configure-vnc-server-centos-7-rhel-7/ 它仍然不起作用。我在这里记录解决方案,以防其他人遇到这种情况。
解决方案: 删除了 Nvidia 驱动程序并将其替换为 xorg-x11-drv-nouveau。这解决了问题。以下是我删除它的方法: https://ask.fedoraproject.org/en/question/78969/how-to-remove-the-nvidia-proprietary-driver/
此后我进行了一些搜索,看到有人提到 Nvidia 驱动程序破坏了 VNC,尽管它对于有线显示器来说运行良好。
答案2
尝试启动两个进程:
systemctl 启动 vncserver-x11-serviced systemctl 启用 vncserver-x11-serviced systemctl 启动 vncserver-vrituald systemctl 启用 vncserver-vrituald
启动 vncserver