赞
踩
##### 查看当前系统版本
**[root@192 system]# cat /etc/.productinfo**
**NeoKylin Linux Advanced Server release V7Update6/(Chromium)-x86_64 b4.lic/20190820
##### 查看是否安装VNC**
**[root@192 system]# rpm -qa | grep vnc**
**tigervnc-server-minimal-1.8.0-13.el7.x86_64**
**gtk-vnc2-0.7.0-3.el7.x86_64**
**tigervnc-1.8.0-13.el7.x86_64**
**tigervnc-icons-1.8.0-13.el7.noarch**
**tigervnc-server-1.8.0-13.el7.x86_64**
**gvnc-0.7.0-3.el7.x86_64**
**tigervnc-license-1.8.0-13.el7.noarch
yum install tigervnc-server
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
第一次执行会要求设置用于客户端通过vnc连接该用户的密码,以后想更改可以通过vncpasswd更改该连接密码。注意最后问是否设置一个只读密码要选否,否则客户端登陆只会看到一个黑屏: 默认是从1开始
[root@192 system]# vncserver
You will require a password to access your desktops.
Password:
Verify:
Would you like to enter a view-only password (y/n)? n
A view-only password is not used
New '192.168.92.152:1 (kylin)' desktop is 192.168.92.152:1
Creating default startup script /root/.vnc/xstartup
Creating default config /root/.vnc/config
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/192.168.92.152:1.log
vim /etc/systemd/system/vncserver@:1.service
[Unit] Description=Remote desktop service (VNC) After=syslog.target network.target [Service] Type=forking Clean any existing files in /tmp/.X11-unix environment ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :' ExecStart=/usr/sbin/runuser -l root -c "/usr/bin/vncserver %i" PIDFile=/root/.vnc/%H%i.pid ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :' [Install] WantedBy=multi-user.target
systemctl daemon-reload
systemctl start vncserver@:1.service -----启动
systemctl enable vncserver@:1.service -----开机自启
systemctl stop firewalld --关闭防火墙
systemctl disable firewalld --开机关闭
或者开启防火墙添加5901端口(这里只开启一个端口,如有多个界面可以开启多个端口):
systemctl start firewalld
firewall-cmd *--permanent --zone=public --add-port=5901/tcp
输入vncservice 开启服务,输入提示登陆的ip:prot
服务重启正常,网络连接正常,使用VNC Viewer
修改配置文件中对应的用户/.vnc/路径,如果是root用户/root/ .vnc 如果是普通用户/home/kylin/ .vnc
如果使用VNC客户端连接服务器超时,查看防火墙是否关闭,服务是否正常,vncservice启动VNC
[root@wyx system]*# netstat -antulp | grep 5901* tcp 0 0 0.0.0.0:5901 0.0.0.0:* LISTEN 5008/Xvnc tcp6 0 0 :::5901 :::* LISTEN 5008/Xvnc [root@wyx system]*# ps -ef | grep vnc* root 5008 1 0 19:45 pts/0 00:00:00 /usr/bin/Xvnc :1 -auth /root/.Xauthority - desktop wyx.pc.com:1 (root) -fp catalogue:/etc/X11/fontpath.d -geometry 1024x768 -pn -rfbauth /root/.vnc/passwd -rfbport 5901 -rfbwait 30000 root 5678 1640 0 19:48 pts/0 00:00:00 grep --color=auto vnc 关闭服务: vncserver -kill :1 启动服务 vncserver :n (端口号=5900+n) 启动时可以同时启动过个进程来分配给不同用户,n不同即可 vncserver :1 vncserver :2 vncserver :3 netstat -antulp | grep 59 tcp 0 0 0.0.0.0:5901 0.0.0.0:* LISTEN 6510/Xvnc tcp 0 0 0.0.0.0:5902 0.0.0.0:* LISTEN 11064/Xvnc tcp 0 0 0.0.0.0:5903 0.0.0.0:* LISTEN 12457/Xvnc tcp 0 0 192.168.0.103:5901 125.71.203.215:65313 ESTABLISHED 6510/Xvnc tcp6 0 0 :::5901 :::* LISTEN 6510/Xvnc tcp6 0 0 :::5902 :::* LISTEN 11064/Xvnc tcp6 0 0 :::5903 :::* LISTEN 12457/Xvnc 杀掉已经启动的进程 pkill -9 vnc 清空配置缓存(删除X1即可,也可以根据需要全部删除) [root@wyx .X11-unix]# ls /tmp/.X11-unix X0 X1 X2 X3 X4 X5 X6 保留config passwd xstartup即可 [root@wyx .vnc]# ls /root/.vnc/ config wyx.pc.com:1.log wyx.pc.com:2.pid wyx.pc.com:3.pid wyx.pc.com:4.pid passwd wyx.pc.com:2.log wyx.pc.com:3.log wyx.pc.com:4.log xstartup 现在可以通过systemd管理服务了 systemctl start vncserver@:1.service netstat -antulp | grep 59 tcp 0 0 0.0.0.0:5901 0.0.0.0:* LISTEN 5611/Xvnc tcp6 0 0 :::5901 :::* LISTEN 5611/Xvnc 查看报错信息:grep vnc /var/log/messages
.0.0:* LISTEN 5611/Xvnc
tcp6 0 0 :::5901 ::
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。