RHEL Linux6.3下的vnc安装和多用户配置推荐

VNC (Virtual Network Computer)是虚拟网络计算机的缩写。VNC 是一款优秀的远程控制工具软件,由著名的 AT T 的欧洲研究实验室开发的。VNC 是在基于 UNIX 和 Linux 操作系统的免费的开源软件,远程控制能力强大,高效实用,其性能可以和 Windows 和 MAC 中的任何远程控制软件媲美。 在 Linux 中,VNC 包括以下四个命令:vncserver,vncviewer,vncpasswd,和vncconnect。大多数情况下用户只需要其中的两个命令:vncserver 和 vncviewer。下面我们讲一下在RHEL Linux6.3下的vnc安装和多用户配置。

一、安装VNC

RHEL6.3中有关VNC的rpm包是:

客户端:tigervnc-1.0.90-0.17.20110314svn4359.el6.x86_64.rpm

服务端:tigervnc-server-1.0.90-0.17.20110314svn4359.el6.x86_64.rpm

1、yum安装:(配置本地YUM源)

[root@localhost]#mkdir /rhel6

[root@localhost]#mount -o loop -t iso9660rhel-server-6.3-x86_64-dvd.iso /rhel6

[root@localhost yum.repos.d]# cat rhel6.repo

[rhel6]

name=Red Hat Enterprise Linux6.3

baseurl=file:///rhel6

enabled=1

gpgcheck=0

[root@localhost]#yum makecache

[root@rac1 oracle]# yum -y install tigervnc-server

Loaded plugins: product-id, refresh-packagekit, security, subscription-manager

Installing : tigervnc-server-1.0.90-0.17.20110314svn4359.el6.x86_64 1/1

Installed products updated.

Verifying : tigervnc-server-1.0.90-0.17.20110314svn4359.el6.x86_64 1/1

Installed:

tigervnc-server.x86_64 0:1.0.90-0.17.20110314svn4359.el6

Complete!

2、启动vnc服务

#service vncserver start

3、添加系统启动

#chkconfig vncserver on

4、启动VNC桌面

[root@rac1 oracle]# vncserver

You will require a password to access your desktops.

Password:

Verify:

xauth: creating new authority file /root/.Xauthority

New ‘rac1.localdomain:1 (root)’ desktop is rac1.localdomain:1

Creating default startup script /root/.vnc/xstartup

Starting applications specified in /root/.vnc/xstartup

Log file is /root/.vnc/rac1.localdomain:1.log

注: 第一次启动时系统会提示设置连接VNC时的登录密码,这个和ROOT设置的认证密码是可以不同的。

二、配置VNC

查看vnc桌面配置文件

[root@bogon ~]# vi /root/.vnc/xstartup

#######################################################################

1 #!/bin/sh

2

3 [ -r /etc/sysconfig/i18n ] . /etc/sysconfig/i18n

4 export LANG

5 export SYSFONT

6 vncconfig -iconic

7 unset SESSION_MANAGER

8 unset DBUS_SESSION_BUS_ADDRESS

9 OS=`uname -s`

10 if [ $OS = ‘Linux’ ]; then

11 case “$WINDOWMANAGER” in

12 *gnome*)

13 if [ -e /etc/SuSE-release ]; then

14 PATH=$PATH:/opt/gnome/bin

15 export PATH

16 fi

17 ;;

18 esac

19 fi

20 if [ -x /etc/X11/xinit/xinitrc ]; then

21 exec /etc/X11/xinit/xinitrc

22 fi

23 if [ -f /etc/X11/xinit/xinitrc ]; then

24 exec sh /etc/X11/xinit/xinitrc

25 fi

26 [ -r $HOME/.Xresources ] xrdb $HOME/.Xresources

27 xsetroot -solid grey

28 xterm -geometry 80×24+10+10 -ls -title “$VNCDESKTOP Desktop”

29 twm

######################################################################################

注: 左边的1-29是VIM显示的行号,便于编辑。

第7行和第21或24行在红帽5版本中默认是被注释掉的,是要启用的,RHEL6.3是默认是启用的。

只需要把最后一句twm 改为gnome-session 即可。

然后vncserver -kill :1

再vncserver :1启用一下,就可以使用客户端正常连接了。(注:需关闭防火墙或放行相应端口)

三、多用户配置

修改vncserver配置文件

[root@bogon ~]# vi /etc/sysconfig/vncservers

#####################################################################################

1 # The VNCSERVERS variable is a list of display:user pairs.

2 #

3 # Uncomment the lines below to start a VNC server on display :2

4 # as my ‘myusername’ (adjust this to your own). You will also

5 # need to set a VNC password; run ‘man vncpasswd’ to see how

6 # to do that.

7 #

8 # DO NOT RUN THIS SERVICE if your local area network is

9 # untrusted! For a secure way of using VNC, see this URL:

10 # http://kbase.redhat.com/faq/docs/DOC-7028

11

12 # Use “-nolisten tcp” to prevent X connections to your VNC server via TC P.

13

14 # Use “-localhost” to prevent remote VNC clients connecting except when

15 # doing so through a secure tunnel. See the “-via” option in the

16 # `man vncviewer’ manual page.

17

18 #VNCSERVERS=”2:myusername”

19 #VNCSERVERARGS[2]=”-geometry 800×600 -nolisten tcp -localhost”

##########################################################################################

注:把18、19行复制一下,做如下修改

VNCSERVERS=”1:root 2:test”

VNCSERVERARGS[3]=”-geometry 800×600 -nolisten tcp -localhost”

如果启用更多用户,则可以直接空格再继续同格式添加用户,例,VNCSERVERS=”1:root 2:test 3:user” 但是第19行的[3],一定要改成第18行启用的用户数加上1,比如上面两个用户,就要写成3,那么3个用户就写成4。不然的话,vncserver重启后,最后一个用户的vnc桌面不可用,但是如果以上用户又启用了其他桌面号但没写进这个文件,不受影响。另外在TEST用户下也需要启用VNCSERVER服务并设置密码,修改相应的配置文件。

重启VNC服务

# service vncserver restart

# xhost +

关闭防火墙

#service iptables stop

#chkconfig iptables off

多用户测试:

WINDOWS系统环境下使用vnc客户端连接时,输入IP地址时一定要跟上桌面号,例:“192.168.199.109:1”“192.168.199.109:2”。这样就可以分别登陆到ROOT桌面和TEST用户桌面。

补充:

远程连入UNIX、Linux进行图形化操作的还有流行的Xmanager软件,VNC与之相比——两者工作原理不一样,前者(VNC)是远程连入操作系统,所有操作在UNIX、Linux主机服务端进行,即使操作过程中“本地电脑与操作主机网络断开”,也不影响操作的顺利进行;而后者(Xmanager)是通过端口将主机服务器的UI界面引导到本地电脑进行展现,如操作过程出现“本地电脑与操作主机网络断开”,操作将中断失败!如果操作中进行的工作任务非常重要,不能中断,如ORACLE RAC实施,结果是灾难性的!更重要的是,VNC是免费的、开源的,Xmanager你可能用的是破解注册版的。

陪我们走过一段别人无法替代的记忆。

RHEL Linux6.3下的vnc安装和多用户配置推荐

相关文章:

你感兴趣的文章:

标签云: