Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6547059
  • 博文数量: 1005
  • 博客积分: 8199
  • 博客等级: 中将
  • 技术积分: 13071
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-25 20:19
个人简介

脚踏实地、勇往直前!

文章分类

全部博文(1005)

文章存档

2020年(2)

2019年(93)

2018年(208)

2017年(81)

2016年(49)

2015年(50)

2014年(170)

2013年(52)

2012年(177)

2011年(93)

2010年(30)

分类: LINUX

2012-01-12 10:08:53

环境:Linux Red Hat As 4
步骤1:检查是否安装了vnc server
[root@hxl oracle]# rpm -qa|grep vnc
vnc-4.0-8.1
vnc-server-4.0-8.1
若没有安装可以在linux 安装介质中找到vnc相关的软件包安装(安装过程这里略过).
 
步骤2:配置
1.配置Linux主机
1).[root@hxl]#vncserver :1 #启动vnc server
2).[root@hxl]#vim ~/.vnc/xstartup
将xstartup文件中的内容twm&注释掉,加入/usr/bin/startkde&(KDE桌面) 或 /usr/bin/gnome-session&(GNOME桌面) startkde& #表示远程客户端将登陆Linux的KDE桌面(显示效果不太好)
gnome-session& #表示远程客户端将登陆Linux的GNOME桌面.
xstartup文件默认的内容如下
#!/bin/sh
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm &
 
修改后内容如下:
#!/bin/sh
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
gnome-session&
 
3).[root@hxl]#vncserver -kill :1 //vnc服务桌面号1,注意kill和:之间需要空格.
[root@gliethttp root]#vncserver :1 //重启vnc服务桌面号1
 
4).[root@hxl]#vncpasswd //设置登陆密码
 
步骤3:通过vnc登陆
方法1:使用vnc windows客户端登录,输入服务器地址后(如:192.168.30.33:1),提示输入密码后即可登录linux.
 
若登录以后看到的是灰色界面,需要配置/etc/hosts文件,将ip地址和hostname对应起来.
[root@hxl ~]# more /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1               localhost.localdomain localhost
::1             localhost6.localdomain6 localhost6
192.168.30.33   hxl.com hxl
修改完成后需要重启网络
[root@hxl .vnc]# service network restart
方法2:使用Web浏览器登陆,地址栏输入,提示输入密码后即可登录linux.
 
5.配置/etc/sysconfig/vncservers
定义VNCSERVERS
如下:
 
VNCSERVERS="1:root"
定义root用户使用1桌面号.
 
备注:
使用vncserver命令启动VNC服务,命令格式为“vncserver :桌面号,其中"桌面号"用"数字"的方式表示,每个用户连个需要占用1个桌面.如:vncserver :1 启动桌面号1,vncserver :2 启动桌面号2.

VNC服务使用的端口号与桌面号的关系
VNC服务使用的端口号与桌面号相关,VNC使用TCP端口从5900开始,对应关系如下
桌面号为“1”  ---- 端口号为5901
桌面号为“2”  ---- 端口号为5902
桌面号为“3”  ---- 端口号为5903
……
基于Java的VNC客户程序Web服务TCP端口从5800开始,也是与桌面号相关,对应关系如下
桌面号为“1”  ---- 端口号为5801
桌面号为“2”  ---- 端口号为5802
桌面号为“3”  ---- 端口号为5803
……
基于上面的介绍,如果Linux开启了防火墙功能,就需要手工开启相应的端口,以开启桌面号为“1”相应的端口为例,命令如下
[root@testdb ~]# iptables -I INPUT -p tcp --dport 5901 -j ACCEPT
[root@testdb ~]# iptables -I INPUT -p tcp --dport 5801 -j ACCEPT

说明:
1.若从主机copy后无法粘贴,可以运行vncconfig

将这三个选项打上勾既可.

阅读(7425) | 评论(1) | 转发(2) |
给主人留下些什么吧!~~

桔色花花朵2012-01-12 21:38:19

恩,( ^_^ )不错嘛,学习了~