All things are difficult before they are easy. 没有软件的裸机是一具僵尸,没有硬件的软件是一个幽灵。2012,专注于Linux和C语言,关注自动化、性能测试,关注开源社区和开源测试工具、方法,尝试测试团队管理!

VNC简介及RedHat中VNC的设置和使

上一篇 / 下一篇  2011-02-19 00:52:31 / 个人分类:软件应用

公司的RHEL5u5服务器上设置VNC时,由于我开始不太明白,导致没设置成功,后来google了些资料看了,结合自己的一些实践,对VNC的配置和使用都比较清楚了,下面简单记录一下,以RedHat系统中VNC为例。
0.What's VNC ?
In computing,Virtual Network Computing (VNC)is a graphical desktop sharing system that uses the RFB protocol to remotely control another computer. It transmits the keyboard and mouse events from one computer to another, relaying the graphical screen updates back in the other direction, over a network.
VNC is platform-independent – a VNC viewer on one operating system may connect to a VNC server on the same or any other operating system. There are clients and servers for many GUI-based operating systems and for Java. Multiple clients may connect to a VNC server at the same time. Popular uses for this technology include remote technical support and accessing files on one's work computer from one's home computer, or vice versa.
VNC is a open source software under the GNU General Public License.
1.install vnc 安装VNC
在redhat中安装vnc server: rpm -ivh vnc-server-4.1.2-9.el5.rpm
检查是否已经安装vnc的rpm包:rpm -qa | grep vnc
2.configure vnc 配置VNC
设置登陆用户桌面环境信息
 #vi /etc/sysconfig/vncservers添加:
  VNCSERVERS="1:root 2:master"  #添加用户名机设置用户登陆的桌面环境信息, 这里表示,1号桌面对应root账号,2号桌面对应master账号。
 VNCSERVERARGS[1]="-geometry 800x600"
 VNCSERVERARGS[2]="-geometry 800x600"
 #参数说明:
-geometry 800x600 桌面分辨率
-nolisten tcp 阻止通过TCP连接VNC服务器
-nohttpd 阻止基于浏览器的VNC客户端连接。用浏览器的方式连接VNC图象质量不大满意,速度也不快,也不安全。如果没有禁止浏览器Applet窗口登录,我们可以在浏览器里输入:[url]http://vnc-server-ip:5802[/url] 这样就会出弹出来一个类似VNC viewer客户端的登录小窗口。
VNC服务使用的端口号与桌面号的关系
  VNC服务使用的端口号与桌面号相关,VNC使用TCP端口从5900开始,对应关系如下
  桌面号为“1” ---- 端口号为5901  #vncviewer链接的tcp端口号  5900+1
  桌面号为“2” ---- 端口号为5902
  ……
  基于Java的VNC客户程序Web服务TCP端口从5800开始,也是与桌面号相关,对应关系如下
  桌面号为“1” ---- 端口号为5801  #http协议网络连接的端口号  5800+1
  桌面号为“2” ---- 端口号为5802
  ……
  基于上面的介绍,如果Linux开启了防火墙功能,就需要手工开启相应的端口,以开启桌面号为“1”相应的端口为例,命令如下:
  [root@testdb ~]# iptables -I INPUT -p tcp --dport 5901 -j ACCEPT
  [root@testdb ~]# iptables -I INPUT -p tcp --dport 5801 -j ACCEPT
 命令vncpasswd建立登录vnc-server的密码。
 配置启动vnc的X界面/home/root/.vnc/xstartup   #这个文件是配置root账号的,账号根据实际情况选择
  去掉如下两行的注释
  unset SESSION_MANAGER
  exec /etc/X11/xinit/xinitrc
 配置桌面环境,将这个xstartup文件的最后一行修改为“startkde &”,再重新启动vncserver服务后就可以登陆到KDE桌面环境
 将这个xstartup文件的最后一行修改为“gnome-session &”,再重新启动vncserver服务后就可以登陆到GNOME桌面环境
3.start vncserver 启动vncserver
如果已经配置好了上面的配置文件,启动命令: service vncserver start
如果想启动其中一个桌面,则可用:vncserver :2     #就启动了序号为2的桌面的vnc服务
4.vncviewers connect to vncserver  连接vnc服务器
  4.1 redhat终端中,vncviewer Ip:x   #x为桌面号,或者为5901(5900+1)这样的vnc端口
  4.2 在web浏览器中,输入:http://IP:y #y为5800+x,x为桌面编号
5.stop vnc service 关闭vnc服务
service vncserver stop
关闭一个vnc桌面,vncserver -kill x   #kill掉了x号桌面
6.other useful commands 其他一些有用的命令
service vncserver status   #查看vncserver的运行状态
service vncserver restart  #重新启动svnserver
   设置VNC服务随系统启动自动加载
  第一种方法:使用“ntsysv”命令启动图形化服务配置程序,在vncserver服务前加上星号,点击确定,配置完成。
  第二种方法:使用“chkconfig”在命令行模式下进行操作,命令使用如下(预知chkconfig详细使用方法请自助式man一下)
  [root@testdb ~]# chkconfig vncserver on
  [root@testdb ~]# chkconfig --list vncserver
  vncserver 0:off 1:off 2:on 3:on 4:on 5:on 6:off

参考资料:
http://snailwarrior.blog.51cto.com/680306/141392
http://www.jz123.cn/text/0133176.html
http://www.xiaofeng.org/article/20090422360.htm
http://nic.dlou.edu.cn/s/14/t/21/0d/25/info3365.htm
http://www.51testing.com/?uid-64098-action-viewspace-itemid-142803
http://wenda.tianya.cn/wenda/thread?tid=3be1f26dea527034

TAG: Linux linux VNC vnc

山草小屋 引用 删除 paulinetina   /   2014-03-26 13:22:52
写的很详细!
山草小屋 引用 删除 paulinetina   /   2014-03-26 13:22:28
5
笑遍世界的测试技术 引用 删除 smile665   /   2011-03-03 14:21:09
在ubuntu系统上使用vncserver时,可能还需要对xinitrc添加可执行权限:
sudo chmod 755 /etc/X11/xinit/xinitrc
而且很多参数可以在/usr/bin/vnc4server文件中修改哦
 

评分:0

我来说两句

smile665

smile665

Stay hungry, stay foolish. 得意之时谨记,一半命运还掌握在上帝手里;失意之时须知,一半命运还掌握在自己手里。

日历

« 2024-03-25  
     12
3456789
10111213141516
17181920212223
24252627282930
31      

数据统计

  • 访问量: 952416
  • 日志数: 220
  • 建立时间: 2008-11-06
  • 更新时间: 2012-10-06

RSS订阅

Open Toolbar