我正在使用 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 文件,但是除了空白的空白屏幕或带有复选框的屏幕之外,它们都没有产生结果。
如果有这方面经验的人对更多故障排除提出建议,或者您能够看到问题所在,请提出您的想法。
遵循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,即使它适用于有线显示器。
尝试启动两个过程:
systemctl start vncserver-x11-serviced systemctl enable vncserver-x11-serviced systemctl start vncserver-vrituald systemctl enable vncserver-vrituald
启动 vncserver