错误如题所示,具体如下:

在我的环境中:
192.168.72.134上启用了NXServer端程序,它开放了4000端口以供客户端的NoMachine去访问图形化的窗口。

而在出现上面截图所示的如题问题的时候,在NX的服务端的后台是有日志的,具体如下:

日志文件:【/usr/NX/var/log/nxserver.log】

2019-09-27 19:21:28 935.667  3585 NXSERVER User 'root' logged in from '192.168.72.1' using authentication method NX-password.
2019-09-27 19:21:30 303.672  1454 NXSERVER WARNING! Cannot retrieve node socket for session 90A87E9188B99EA1786321DDCBBED7DB.
2019-09-27 20:33:49 459.958  1474 NXNODE   ERROR! Application terminated too early.
2019-09-27 20:33:50 140.869  3585 NXSERVER User 'root' from '192.168.72.1' logged out.

看看我们的NX的服务端的服务情况:

[root@dev-python pycharm-2019.2.3]# /usr/NX/bin/nxserver --version
NoMachine - Version 6.8.1
[root@dev-python pycharm-2019.2.3]# 
[root@dev-python pycharm-2019.2.3]# /usr/NX/bin/nxserver --status
NX> 111 New connections to NoMachine server are enabled.
NX> 162 Enabled service: nxserver.
NX> 162 Disabled service: nxnode.
NX> 162 Enabled service: nxd.
[root@dev-python pycharm-2019.2.3]# 
[root@dev-python pycharm-2019.2.3]# netstat -tupln | grep 4000
tcp        0      0 0.0.0.0:4000                0.0.0.0:*                   LISTEN      4929/nxd            
tcp        0      0 :::4000                     :::*                        LISTEN      4929/nxd            
[root@dev-python pycharm-2019.2.3]# 
[root@dev-python pycharm-2019.2.3]# netstat -tupln | grep nx
tcp        0      0 0.0.0.0:4000                0.0.0.0:*                   LISTEN      4929/nxd            
tcp        0      0 127.0.0.1:12001             0.0.0.0:*                   LISTEN      5765/nxnode.bin     
tcp        0      0 127.0.0.1:20002             0.0.0.0:*                   LISTEN      5745/nxserver.bin   
tcp        0      0 127.0.0.1:20135             0.0.0.0:*                   LISTEN      1109/nxserver.bin   
tcp        0      0 127.0.0.1:25001             0.0.0.0:*                   LISTEN      5827/nxclient.bin   
tcp        0      0 127.0.0.1:26001             0.0.0.0:*                   LISTEN      5765/nxnode.bin     
tcp        0      0 0.0.0.0:7001                0.0.0.0:*                   LISTEN      5765/nxnode.bin     
tcp        0      0 :::4000                     :::*                        LISTEN      4929/nxd            
tcp        0      0 :::7001                     :::*                        LISTEN      5765/nxnode.bin     
udp    23592      0 192.168.72.134:5353         0.0.0.0:*                               1109/nxserver.bin   
udp        0      0 0.0.0.0:5353                0.0.0.0:*                               1109/nxserver.bin   
[root@dev-python pycharm-2019.2.3]# 

看看NoMachine所在的目录【/usr/NX】

[root@dev-python ~]# cd /usr/NX/
[root@dev-python NX]# 
[root@dev-python NX]# ls -ltrd ../
drwxr-xr-x. 15 root root 4096 Sep 27 18:39 ../
[root@dev-python NX]# 
[root@dev-python NX]# ls -ltr
total 24
drwxr-xr-x. 12 root root 4096 Sep 11 17:13 scripts
drwxr-xr-x.  3 root root 4096 Sep 27 08:15 lib
drwxr-xr-x. 19 root root 4096 Sep 27 08:15 share
drwxr-xr-x.  6 nx   root 4096 Sep 27 08:15 var
drwxr-xr-x.  3 root root 4096 Sep 27 08:15 bin
drwxr-xr-x.  3 nx   root 4096 Sep 27 20:53 etc
[root@dev-python NX]# 
[root@dev-python NX]# tree /usr/NX/ -L 2 | grep -v ".db$" | grep -v ".so$" | grep -v ".lock$" | grep -v ".sample$"
/usr/NX/
├── bin
│   ├── drivers
│   ├── nxagent
│   ├── nxauth
│   ├── nxclient
│   ├── nxclient.bin
│   ├── nxcodec.bin
│   ├── nxcuinit
│   ├── nxd
│   ├── nxesd
│   ├── nxexec
│   ├── nxfs
│   ├── nxfsm
│   ├── nxfsserver
│   ├── nxkb
│   ├── nxkeygen
│   ├── nxlocate
│   ├── nxlpd
│   ├── nxnode
│   ├── nxnode.bin
│   ├── nxplayer
│   ├── nxplayer.bin
│   ├── nxpost
│   ├── nxprint
│   ├── nxserver
│   ├── nxserver.bin
│   ├── nxsh
│   ├── nxspool
│   ├── nxssh
│   ├── nxssh-add
│   ├── nxssh-agent
│   ├── nxtunctl
│   └── nxusbd
├── etc
│   ├── keys
│   ├── node.cfg
│   ├── node.lic
│   ├── server.cfg
│   ├── server.lic
│   ├── sshstatus
│   ├── update.cfg
│   ├── uuid
│   └── version
├── lib
│   ├── libstdc++.so.6 -> libstdc++.so.6.0.20
│   ├── libstdc++.so.6.0.20
│   └── perl
├── scripts
│   ├── env
│   ├── etc
│   ├── init
│   ├── lb
│   ├── log
│   ├── nxpasswdask.sh
│   ├── restricted
│   ├── selinux
│   ├── setup
│   ├── systemd
│   └── vgl
├── share
│   ├── applnk
│   ├── audio
│   ├── branding
│   ├── cups
│   ├── cursors
│   ├── documents
│   ├── fail2ban
│   ├── icons
│   ├── images
│   ├── keyboards
│   ├── keymaps
│   ├── keymaps-windows
│   ├── keys
│   ├── layouts
│   ├── locale
│   ├── mimetypes
│   ├── policy
│   ├── rgb
│   ├── sounds
│   ├── src
│   └── X11
└── var
    ├── log
    ├── run
    └── tmp

40 directories, 158 files
[root@dev-python NX]# 

NX的配置文件位于【/usr/NX/etc】

[root@dev-python etc]# pwd
/usr/NX/etc
[root@dev-python etc]# 
[root@dev-python etc]# ls -ltr | grep .cfg$
-rw-r--r--. 1 nx   root 40464 Sep 11 16:11 update.cfg
-rw-r--r--  1 nx   nx   45745 Sep 27 20:45 server.cfg
-rw-r--r--  1 nx   nx   30041 Sep 27 20:53 node.cfg
[root@dev-python etc]# 

看看当前配置文件【node.cfg】的情况:

[root@dev-python etc]# pwd
/usr/NX/etc
[root@dev-python etc]# 
[root@dev-python etc]# cat node.cfg | grep -v "^#" | strings
ConfigFileVersion 4.0
DefaultDesktopCommand "/etc/X11/Xsession default"
AvailableSessionTypes unix-remote,unix-console,unix-default,unix-application,physical-desktop,shadow
EnableSmartcardSharing 1
AudioInterface alsa
EnableCUPSSupport 1
CUPSBinPath /usr/bin
CUPSSbinPath /usr/sbin
CUPSBackendPath /usr/lib/cups/backend
EnableSMBFSSupport 1
CommandFuser /sbin/fuser
CommandLsof /usr/sbin/lsof
DefaultXSession "/etc/X11/Xsession default"
ClientConnectionMethods NX,SSH
DisplayServerThreads auto
DisplayEncoderThreads auto
EnableDirectXSupport 0
[root@dev-python etc]# 

请注意:

  1. 【DefaultDesktopCommand】和【DefaultXsession】指向的命令都是【/etc/X11/Xsession】

如果是上面这样的配置,那么就会出现文首的错误

nxerror.log

Info: Handler started with pid 7909 on Fri Sep 27 21:19:59 2019.
Info: Handling connection from 192.168.72.1 port 6946 on Fri Sep 27 21:19:59 2019.
Info: Connection from 192.168.72.1 port 6946 closed on Fri Sep 27 21:20:00 2019.
Info: Handler with pid 7909 terminated on Fri Sep 27 21:20:00 2019.

nxd.log

Info: Connection from 192.168.72.1 port 6946 accepted on Fri Sep 27 21:19:58 2019.
Info: Connection from 192.168.72.1 port 6946 process 7909 started on Fri Sep 27 21:19:58 2019.

nxserver.log

2019-09-27 21:19:59 343.988  7909 NXSERVER User 'root' logged in from '192.168.72.1' using authentication method NX-password.

2019-09-27 21:22:49 244.957  7461 NXNODE   ERROR! Application terminated too early.
2019-09-27 21:22:49 745.612  7909 NXSERVER User 'root' from '192.168.72.1' logged out.

来看看上面配置文件中提到的命令【/etc/X11/Xsession】是否存在:

[root@dev-python ~]# ls -ltr /etc/X11/
total 28
drwxr-xr-x. 2 root root 4096 Jun 28  2011 applnk
-rw-r--r--. 1 root root  493 Nov 22  2013 Xresources
-rw-r--r--. 1 root root  547 Nov 22  2013 Xmodmap
-rwxr-xr-x. 1 root root 1328 Apr 27  2018 prefdm
drwxr-xr-x. 2 root root 4096 Jun 19  2018 xorg.conf.d
drwxr-xr-x. 2 root root 4096 Sep 27 17:43 fontpath.d
drwxr-xr-x. 4 root root 4096 Sep 27 17:43 xinit
[root@dev-python ~]# 

并不存在。

因此错误原因找到了,因为NX连接服务器端的时候,配置文件中的默认创建GUI会话的命令【/etc/X11/Xsession】并不存在,因此,图形界面打开报错。

修复问题:

在GNOME环境中,图形会话的另一个命令是【gnome-session】

[root@dev-python ~]# whereis gnome-session
gnome-session: /usr/bin/gnome-session /usr/lib64/gnome-session /usr/share/gnome-session /usr/share/man/man1/gnome-session.1.gz
[root@dev-python ~]# 
[root@dev-python ~]# which gnome-session
/usr/bin/gnome-session
[root@dev-python ~]# 

修改NX的配置文件:node.cfg中的【DefaultDesktopCommand / DefaultXSession】

[root@dev-python ~]# cat /usr/NX/etc/node.cfg | grep -v "^#" | strings
ConfigFileVersion 4.0
DefaultDesktopCommand "/usr/bin/gnome-session"
AvailableSessionTypes unix-remote,unix-console,unix-default,unix-application,physical-desktop,shadow
EnableSmartcardSharing 1
AudioInterface alsa
EnableCUPSSupport 1
CUPSBinPath /usr/bin
CUPSSbinPath /usr/sbin
CUPSBackendPath /usr/lib/cups/backend
EnableSMBFSSupport 1
CommandFuser /sbin/fuser
CommandLsof /usr/sbin/lsof
DefaultXSession "/usr/bin/gnome-session"
ClientConnectionMethods NX,SSH
DisplayServerThreads auto
DisplayEncoderThreads auto
EnableDirectXSupport 0
[root@dev-python ~]# 

重启NX服务,以便让上述配置生效:

[root@dev-python ~]# /usr/NX/bin/nxserver --status
NX> 111 New connections to NoMachine server are enabled.
NX> 162 Enabled service: nxserver.
NX> 162 Disabled service: nxnode.
NX> 162 Enabled service: nxd.
[root@dev-python ~]# 
[root@dev-python ~]# netstat -tupln | grep 4000
tcp        0      0 0.0.0.0:4000                0.0.0.0:*                   LISTEN      7411/nxd            
tcp        0      0 :::4000                     :::*                        LISTEN      7411/nxd            
[root@dev-python ~]# 
[root@dev-python ~]# /usr/NX/bin/nxserver --stop nxd
NX> 162 Disabled service: nxd.
[root@dev-python ~]# 
[root@dev-python ~]# netstat -tupln | grep 4000
[root@dev-python ~]# 
[root@dev-python ~]# /usr/NX/bin/nxserver --start nxd
NX> 161 Enabled service: nxd.
[root@dev-python ~]# 
[root@dev-python ~]# /usr/NX/bin/nxserver --status
NX> 111 New connections to NoMachine server are enabled.
NX> 162 Enabled service: nxserver.
NX> 162 Disabled service: nxnode.
NX> 162 Enabled service: nxd.
[root@dev-python ~]# 
[root@dev-python ~]# netstat -tupln | grep 4000
tcp        0      0 0.0.0.0:4000                0.0.0.0:*                   LISTEN      8281/nxd            
tcp        0      0 :::4000                     :::*                        LISTEN      8281/nxd            
[root@dev-python ~]# 

这样就重启生效完成了。

再次用NX的客户端去连接服务端:

可以看到,修复完成后,NX的远程连接与抓取图形界面都正常了。

来看看这时候系统进程的情况:

[root@dev-python ~]# ps -ef | grep gnome-session
root       2702   2684  0 18:29 ?        00:00:00 gnome-session
root       8383   8345  0 21:33 ?        00:00:00 /usr/bin/gnome-session
root       8418      1  0 21:33 ?        00:00:00 dbus-launch --exit-with-session /usr/bin/gnome-session
root       8876   3147  0 21:34 pts/2    00:00:00 grep gnome-session
[root@dev-python ~]# 

可以发现,多了一个【/usr/bin/gnome-session】的进程;
该进程就是我们在【node.cfg】中指定的DefaultXSession与DefaultDesktopCommand的命令。


至此,文首遇到的NoMachine无法连接远端服务器图形界面的问题,已经得到了解决。


说点什么

avatar

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据

  Subscribe  
提醒
隐藏
变装