vncserver 命令未在 CentOS 7 中创建端口(它会立即被终止)

vncserver 命令未在 CentOS 7 中创建端口(它会立即被终止)

执行vncserver命令时得到以下输出,但是在尝试命令时没有列出端口vncserver -list

[user1@localhost ~]$ vncserver 
New 'localhost.localdomain:55 (user1)' desktop is localhost.localdomain:55
Starting applications specified in /home/user1/.vnc/xstartup
Log file is /home/user1/.vnc/localhost.localdomain:55.log

[user1@localhost ~]$ vncserver -list

TigerVNC server sessions:

X DISPLAY # PROCESS ID
[user1@localhost ~]$ 

日志表明它正在终止新创建的端口:

[user1@localhost ~]$ cat /home/user1/.vnc/localhost.localdomain:56.log

Xvnc TigerVNC 1.8.0 - built Aug  9 2019 03:04:19
Copyright (C) 1999-2017 TigerVNC Team and many others (see README.txt)
See http://www.tigervnc.org for information on TigerVNC.
Underlying X server release 12001000, The X.Org Foundation


Sat Nov 27 21:13:18 2021
 vncext:      VNC extension running!
 vncext:      Listening for VNC connections on all interface(s), port 5956
 vncext:      created VNC server for screen 0
/home/user1/.vnc/xstartup: line 5: 31982 Trace/breakpoint trap   (core dumped) /etc/X11/xinit/xinitrc
Killing Xvnc process ID 31890

xstartup文件夹下的文件~/vnc显示如下

[user1@localhost ~]$ cat ~/.vnc/xstartup 
#!/bin/sh

unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
/etc/X11/xinit/xinitrc
# Assume either Gnome or KDE will be started by default when installed
# We want to kill the session automatically in this case when user logs out. In case you modify
# /etc/X11/xinit/Xclients or ~/.Xclients yourself to achieve a different result, then you should
# be responsible to modify below code to avoid that your session will be automatically killed
if [ -e /usr/bin/gnome-session -o -e /usr/bin/startkde ]; then
    vncserver -kill $DISPLAY
fi

我的观察: 如果我vncserver -kill $DISPLAYxstartup文件中注释,端口不会被终止。但通过 VNC Viewer 连接时会显示黑屏。

答案1

在 CentOS 7 中安装的 TigerVNC 服务器将尝试两个桌面服务器:

  1. gnome-经典会话
  2. 桌面环境

Gnome 通常已预装在您的系统中,但经典的桌面。但是,VNC 日志不会通知您缺少此组件。您可以尝试yum install gnome-classic-session并重新运行vncserver,看看问题是否仍然存在。

答案2

gnome 桌面dbus设置max_connections_per_user

vim /etc/dbus-1/system.conf

<busconfig>
  <limit name="max_connections_per_user">100000</limit>
</busconfig>

相关内容