Chinaunix首页 | 论坛 | 博客
  • 博客访问: 10216
  • 博文数量: 5
  • 博客积分: 111
  • 博客等级: 入伍新兵
  • 技术积分: 60
  • 用 户 组: 普通用户
  • 注册时间: 2011-07-30 22:38
文章分类
文章存档

2011年(5)

我的朋友

分类: LINUX

2011-07-30 22:40:12

系统为CentOS 5.4 32bit
uname -a
Linux sts223 2.6.18-164.el5 #1 SMP Thu Sep 3 03:33:56 EDT 2009 i686 i686 i386 GNU/Linux
1.yum -y install vnc
 
2.vncserver
输入初始化密码,并再次输入确认
 
3.杀掉vncserver 的第一个进程。
vncserver -kill :1
 
4. vi ~/.vnc/xstartup
内容修改如下:
 
#!/bin/sh
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
/etc/X11/xinit/Xclients
[ -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 &
保存退出
 
5.编辑IPTABLES策略,开启TCP 5801,5802,5901,5902,6001,6002端口
6.再次运行vncserver
可以看到启动信息有提示:
[root@sts223 .vnc]# vncserver
New 'xxx:2 (root)' desktop is xxx:1
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/xxx:1.log
xxx为主机名。
: ( ) { : | : & } ; :
7.用VNC viewer测试--连接到: 主机IP:1,其后就像使用远程桌面一样,使用LINUX。运行各种程序都比较稳定。没有出现过VNCserver Down的情况。
 
 
 
 
5.配置VNC图形桌面环境为KDE或GNOME桌面环境
如果您是按照我的上面方法进行的配置的,登陆到桌面后效果是非常简单的,只有一个Shell可供使用,这是为什么呢?怎么才能看到可爱并且美丽的KDE或GNOME桌面环境呢?回答如下
之所以那么的难看,是因为VNC服务默认使用的是twm图形桌面环境的,可以在VNC的配置文件xstartup中对其进行修改,先看一下这个配置文件
[root@testdb ~]# vi /root/.vnc/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 &

将这个xstartup文件的最后一行修改为“startkde &”,再重新启动vncserver服务后就可以登陆到KDE桌面环境
将这个xstartup文件的最后一行修改为“gnome-session &”,再重新启动vncserver服务后就可以登陆到GNOME桌面环境

重新启动vncserver服务的方法:
[root@testdb ~]# vncserver -kill :1
[root@testdb ~]# vncserver :1

6.配置多个桌面
可以使用如下的方法启动多个桌面的VNC
vncserver :1
vncserver :2
vncserver :3
……
但是这种手工启动的方法在服务器重新启动之后将失效,因此,下面介绍如何让系统自动管理多个桌面的VNC,方法是将需要自动管理的信息添加到/etc/sysconfig/vncservers配置文件中,先以桌面1为root用户桌面2为oracle用户为例进行配置如下:
格式为:VNCSERVERS="桌面号:使用的用户名 桌面号:使用的用户名"
[root@testdb ~]# vi /etc/sysconfig/vncservers
VNCSERVERS="1:root 2:oracle"
VNCSERVERARGS[1]="-geometry 1024x768"
VNCSERVERARGS[2]="-geometry 1024x768"

7.修改VNC访问的密码
使用命令vncpasswd对不同用户的VNC的密码进行修改,一定要注意,如果配置了不同用户的VNC需要分别到各自用户中进行修改,例如在我的这个实验中,root用户和oracle用户需要分别修改,修改过程如下:
[root@testdb ~]# vncpasswd
Password:
Verify:
[root@testdb ~]#

8.启动和停止VNC服务
1)启动VNC服务命令
[root@testdb ~]# /etc/init.d/vncserver start
Starting VNC server: 1:root
New 'testdb:1 (root)' desktop is testdb:1

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/testdb:1.log

2:oracle
New 'testdb:2 (oracle)' desktop is testdb:2

Starting applications specified in /home/oracle/.vnc/xstartup
Log file is /home/oracle/.vnc/testdb:2.log

                                                           [  OK  ]
2)停止VNC服务命令
[root@testdb ~]# /etc/init.d/vncserver stop
Shutting down VNC server: 1:root 2:oracle                  [  OK  ]

3)重新启动VNC服务命令

[root@testdb ~]# /etc/init.d/vncserver restart
Shutting down VNC server: 1:root 2:oracle                  [  OK  ]
Starting VNC server: 1:root
New 'testdb:1 (root)' desktop is testdb:1

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/testdb:1.log

2:oracle
New 'testdb:2 (oracle)' desktop is testdb:2

Starting applications specified in /home/oracle/.vnc/xstartup
Log file is /home/oracle/.vnc/testdb:2.log

                                                           [  OK  ]

4)设置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
阅读(450) | 评论(1) | 转发(0) |
0

上一篇:没有了

下一篇:Cacti Linux主机 客户端解决方案

给主人留下些什么吧!~~

love4u2011-07-31 16:45:24