扩大
缩小

vnc server的安装

vnc是一款使用广泛的服务器管理软件,可以实现图形化管理。我在安装vnc server碰到一些问题,也整理下我的安装步骤,希望对博友们有一些帮助。

1 安装对应的软件包

[root@centos6 ~]# yum search vnc
[root@centos6 ~]# yum -y install tigervnc-server

2 设置vnc远程连接密码

[root@centos6 ~]# vncpasswd 
Password:
Verify:

3 修改vncserver配置文件

[root@centos6 ~]# vim /etc/sysconfig/vncservers 
VNCSERVERS="2:root"
VNCSERVERARGS[2]="-geometry 1024x768"

注意:1024x768的中间的那个符号是小写字母x。

4 重启服务并查看服务

[root@centos6 ~]# service vncserver restart #重启vncserver
Shutting down VNC server:                                  [  OK  ]
Starting VNC server: 2:root xauth:  file /root/.Xauthority does not exist
xauth: (stdin):1:  bad display name "centos6.magedu.com:2" in "add" command

New 'centos6.magedu.com:2 (root)' desktop is centos6.magedu.com:2

Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/centos6.magedu.com:2.log

                                                           [  OK  ]
[root@centos6 ~]# netstat -tunlp |grep vnc #发现监听在5902端口上
tcp        0      0 0.0.0.0:5902                0.0.0.0:*                   LISTEN      4269/Xvnc           
tcp        0      0 0.0.0.0:6002                0.0.0.0:*                   LISTEN      4269/Xvnc           
tcp        0      0 :::6002                     :::*                        LISTEN      4269/Xvnc     

5 测试vnc服务

我这里在windows机器使用vncview进行测试。在vncview连接种输入ip:5902,发现连不上去。百度了下,从下面的这个参考地址获取到帮助

参考地址:https://stackoverflow.com/questions/20367822/vnc-server-installed-and-running-but-not-visible-over-the-network)

整理下需要3个步骤:

  1. 确保能ping通vnc server所在的服务器
  2. 临时关闭防火墙
  3. 临时关闭selinux
[root@centos6 ~]# service iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination         
1    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED 
2    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0           
3    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           
4    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22 
5    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited 

Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination         
1    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited 

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination         

[root@centos6 ~]# service iptables stop
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]
[root@centos6 ~]# getenforce
Enforcing
[root@centos6 ~]# setenforce 0

执行上面的操作就可以远程连接了。后续我们还需要把启用防火墙把对应的端口放行,并且设置selinux支持vncserver。

 

posted on 2017-11-09 16:16  LinuxPanda  阅读(3281)  评论(0编辑  收藏  举报

导航