配置错误,但是能用
[root@rac1 sbin]# systemctl status vncserver@:2.service -l
vncserver@:2.service - Remote desktop service (VNC)
Loaded: loaded (/usr/lib/systemd/system/vncserver@:2.service; disabled)
Active: failed (Result: exit-code) since Sun 2015-05-03 21:04:37 HKT; 6s ago
Process: 5212 ExecStart=/sbin/runuser -l root -c /usr/bin/vncserver :2 (code=exited, status=98)
Process: 5209 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill :2 > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
May 03 21:04:37 rac1 systemd[1]: vncserver@:2.service: control process exited, code=exited status=98
May 03 21:04:37 rac1 systemd[1]: Failed to start Remote desktop service (VNC).
May 03 21:04:37 rac1 systemd[1]: Unit vncserver@:2.service entered failed state.
[root@rac1 sbin]#
[root@rac1 system]# netstat -a | grep 590
tcp 0 0 0.0.0.0:5902 0.0.0.0:* LISTEN
unix 3 [ ] STREAM CONNECTED 25907 /run/systemd/journal/stdout
unix 3 [ ] STREAM CONNECTED 25909 /var/run/dbus/system_bus_socket
[root@rac1 system]# ^C
[root@rac1 system]# more vncserver@:2.service
# The vncserver service unit file
#
# Quick HowTo:
# 1. Copy this file to /etc/systemd/system/vncserver@:.service
# 2. Edit and vncserver parameters appropriately
# ("runuser -l -c /usr/bin/vncserver %i -arg1 -arg2")
# 3. Run `systemctl daemon-reload`
# 4. Run `systemctl enable vncserver@:.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
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill :2 > /dev/null 2>&1 || :'
ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver :2"
PIDFile=/root/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill :2 > /dev/null 2>&1 || :'
[Install]
WantedBy=multi-user.target
[root@rac1 system]# ^C
[root@rac1 system]#
RHEL7 配置VNC远程桌面工具
2015年02月06日 ? ? 共 2192字 ? 字号 ? ? 阅读 1,380 次初初接触 Linux,想要彻底抛弃图形界面真心不是一件容易的事情,特别需要开启或关闭某些系统功能时,傻瓜的图形化界面总比仍不娴熟的命令行要靠谱一些,学习是 慢慢积累的过程,不可急也急不来,分享一个 Red Hat Enterprise Linux 7 配置 VNC 的教程给正在学习的朋友!
RHEL7 配置VNC |
第一步
#检查系统是否有安装tigervnc-server软件包
[root@wanghualang ~]# rpm -qa |grep vnc
gtk-vnc2-0.5.2-7.el7.x86_64
gvnc-0.5.2-7.el7.x86_64
tigervnc-server-minimal-1.2.80-0.30.20130314svn5065.el7.x86_64
tigervnc-license-1.2.80-0.30.20130314svn5065.el7.noarch
#当前系统未装tigervnc-server软件包
第二步
#安装tigervnc-server软件包
[root@wanghualang ~]# cd /my/Packages/
[root@wanghualang Packages]# rpm -ivh tigervnc-server-1.2.80-0.30.20130314svn5065.el7.x86_64.rpm
准备中... ################################# [100%]
正在升级/安装...
1:tigervnc-server-1.2.80-0.30.20130################################# [100%]
#已安装tigervnc-server软件包,另外,/my/Packages 这个路径是我自定义的。
第三步
#验证tigervnc-server软件包是否安装
[root@wanghualang ~]# rpm -qa |grep vnc
gtk-vnc2-0.5.2-7.el7.x86_64
tigervnc-server-1.2.80-0.30.20130314svn5065.el7.x86_64
gvnc-0.5.2-7.el7.x86_64
tigervnc-server-minimal-1.2.80-0.30.20130314svn5065.el7.x86_64
tigervnc-license-1.2.80-0.30.20130314svn5065.el7.noarch
第四步
#创建一个新的VNC配置文件,/lib/systemd/system/[email protected],这是一个配置文件模版,可以拷贝一份出来进行相关修改,比如我这里是开启2号窗口作为远程桌面。
[root@wanghualang ~]# cd /lib/systemd/system
[root@wanghualang system]# cp [email protected] vncserver@:2.service
第五步
#使用VI编辑器修改vncserver@:2.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=/sbin/runuser -l wanghualang -c "/usr/bin/vncserver %i"
PIDFile=/home/wanghualang/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
[Install]
WantedBy=multi-user.target
#VI 编辑器使用参考:
第六步
#更新systemctl,使刚才的修改生效
[root@wanghualang system]# systemctl daemon-reload
第七步
#设置用户vnc的密码(即第六步中的wanghualang)
[root@wanghualang system]# vncpasswd wanghualang
Password:
Verify:
#再次输入密码进行确认
第八步
#使用2号窗口启动VNC服务
[root@wanghualang system]# vncserver :2
New 'wanghualang.com:2 (root)' desktop is wanghualang.com:2
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/wanghualang.com:2.log
第九步
在Windows下,安装VNC Viewer,输入正确IP地址、窗口号和密码,即可远程。