天天看點

RHEL6: VNC 服務配置

原連結:http://francs3.blog.163.com/blog/static/4057672720126228104715/

2012-07-22 20:38:04|  分類: Red Hat Linux |  标簽: |舉報 |字号大中小 訂閱

     RHEL6 VNC 服務配置較 5 版本的簡單,5 版本預設不開啟 VNC 的圖形化界面,需要手工

更改配置才可以,而RHEL6 版本則不需要,以下為配置過程。

--環境資訊

VNC RHEL6   服務端: 192.168.1.35  主機名 redhat6

VNC RHEL6   用戶端: 192.168.1.36  主機名 redhatB

VNC Windows 用戶端: 192.168.1.55  主機名 xxxxxxx

一 VNC 服務安裝

      VNC 服務所需的包為 tigervnc.i686,LINUX 用戶端需要的包為 tigervnc.i686。

--1.1 tigervnc 包安裝

 [[email protected] ~]# yum search tigervnc

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

Updating certificate-based repositories.

====================================================== N/S Matched: tigervnc =======================================================

tigervnc.i686 : A TigerVNC remote display system

tigervnc-server.i686 : A TigerVNC server

  Name and summary matches only, use "search all" for everything.

[[email protected] ~]# yum install tigervnc.i686 tigervnc-server.i686

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

Updating certificate-based repositories.

Setting up Install Process

Resolving Dependencies

--> Running transaction check

---> Package tigervnc.i686 0:1.0.90-0.17.20110314svn4359.el6 will be installed

---> Package tigervnc-server.i686 0:1.0.90-0.17.20110314svn4359.el6 will be installed

--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================================================

 Package                         Arch                 Version                                         Repository               Size

====================================================================================================================================

Installing:

 tigervnc                        i686                 1.0.90-0.17.20110314svn4359.el6                 my_repo                 268 k

 tigervnc-server                 i686                 1.0.90-0.17.20110314svn4359.el6                 my_repo                 1.1 M

Transaction Summary

====================================================================================================================================

Install       2 Package(s)

Total download size: 1.4 M

Installed size: 3.6 M

Is this ok [y/N]: y

Downloading Packages:

------------------------------------------------------------------------------------------------------------------------------------

Total                                                                                                12 MB/s | 1.4 MB     00:00    

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

Warning: RPMDB altered outside of yum.

  Installing : tigervnc-1.0.90-0.17.20110314svn4359.el6.i686                                                                    1/2

  Installing : tigervnc-server-1.0.90-0.17.20110314svn4359.el6.i686                                                             2/2

Installed products updated.

Installed:

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

Complete!

You have new mail in /var/spool/mail/root

二 VNC 服務配置

--2.1 修改配置檔案 /etc/sysconfig/vncservers

   在 vncserver 配置檔案 /etc/sysconfig/vncservers 中添加以下内容

 VNCSERVERS="1:postgres 2:usera"

VNCSERVERARGS[1]="-geometry 800x600"

VNCSERVERARGS[2]="-geometry 800x600"

--2.2 postgres 使用者設定 vnc 密碼

 [[email protected] ~]# su - postgres

[[email protected] ~]$ vncpasswd

Password:

Verify:

--2.3 usera 使用者設定 vnc 密碼

 [[email protected] ~]# su - usera

[[email protected] ~]$ vncpasswd

Password:

Verify:

--2.4  開啟 vncserver 服務

 [[email protected] ~]# service vncserver start

Starting VNC server: 1:postgres xauth:  creating new authority file /home/postgres/.Xauthority

New 'redhat6:1 (postgres)' desktop is redhat6:1

Creating default startup script /home/postgres/.vnc/xstartup

Starting applications specified in /home/postgres/.vnc/xstartup

Log file is /home/postgres/.vnc/redhat6:1.log

2:usera xauth:  creating new authority file /home/usera/.Xauthority

New 'redhat6:2 (usera)' desktop is redhat6:2

Creating default startup script /home/usera/.vnc/xstartup

Starting applications specified in /home/usera/.vnc/xstartup

Log file is /home/usera/.vnc/redhat6:2.log

[  OK  ]

也可以如下開啟

[[email protected] soft_bak]# vncserver 

New 'rhedhat6:1 (root)' desktop is rhedhat6:1

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

--2.4 檢視 vncserver 程序

 [[email protected] ~]# ps -ef | grep vnc

postgres 10903     1  1 19:46 ?        00:00:00 /usr/bin/Xvnc :1 -desktop redhat6:1 (postgres) -auth /home/postgres/.Xauthority -geometry 800x600 -rfbwait 30000 -rfbauth /home/postgres/.vnc/passwd -rfbport 5901 -fp catalogue:/etc/X11/fontpath.d -pn

postgres 10909 10908  0 19:46 ?        00:00:00 vncconfig -iconic

usera    10938     1  1 19:46 ?        00:00:00 /usr/bin/Xvnc :2 -desktop redhat6:2 (usera) -auth /home/usera/.Xauthority -geometry 800x600 -rfbwait 30000 -rfbauth /home/usera/.vnc/passwd -rfbport 5902 -fp catalogue:/etc/X11/fontpath.d -pn

usera    11020 11019  0 19:46 ?        00:00:00 vncconfig -iconic

root     11190  9281  1 19:46 pts/1    00:00:00 grep vnc

   備注:為了測試友善,暫時把防火牆關了,如果啟用了防火牆,則需要打開 5901 和 5902 端口。

三  通過 windows 用戶端連接配接測試

--3.1 打開VNC 用戶端

RHEL6: VNC 服務配置

    備注:注意IP位址後面的數字,由于計劃使用  postgres 使用者登陸,是以輸入“192.168.1.35:1”,啟用 1 号執行個體。

--3.2 輸入密碼

RHEL6: VNC 服務配置

    備注: postgres 使用者 vnc 登陸成功,usea 也登陸成功,不詳細示範。

四  通過 RHEL6 用戶端主機 redhatB 測試

--4.1 在另一台 RHEL6 機器上測試       

在另一台 RHEL6 虛拟機圖形化界面測試,執行以下指令,vncviewer 指令需要安裝包

tigervnc.i686中,如果找不到這條指令,說明此包沒安裝。

 [[email protected] ~]# vncviewer 192.168.1.35:1

    備注:上面指令輸入密碼後,可以開啟圖形化界面,如果想同時讓多個 client 端以圖形化界面連接配接,則需要加入

-Shared 參數;如果隻想讓用戶端隻讀,而不能操作,則需要加上 -ViewOnly  參數。

--4.2  以加密的方式開啟VNC 連接配接

          由于 VNC 是明文的網絡協定,通信容易被竊聽; vncviewer 指令提供選項 -via [email protected], 該選項先以

user 身份 ssh 到 host 上的 SSH 服務,然後再嘗試從 host 主機連接配接到 VNC 伺服器,這樣 VNC 将通過 SSH

隧道的方式傳遞資訊,要實作這樣的目标,需要修改配置 ,隻允許 localhost 連接配接 VNC。

-- 修改配置  /etc/sysconfig/vncservers

 VNCSERVERS="1:postgres 2:usera"

VNCSERVERARGS[1]="-geometry 800x600 -localhost"

    備注:配置修改後,重新開機 VNC 服務。    

--從主機 redhatB 機器嘗試連接配接

RHEL6: VNC 服務配置

   備注:此時直接通過 VNC 連接配接 192.168.1.35:1 行不通。

--通過 ssh 加密方式連接配接 VNC

RHEL6: VNC 服務配置

   備注:通過以上 ssh 加密的 vncviewer 則可以開啟連接配接。

五 總結

        VNC 服務能夠非常友善開啟圖形化連接配接,一般在生産維護過程中很少用到圖形化界面,但在某些情況

則很會用到,例如 Oracle 資料庫的安裝等,是以在特定的時候通過 VNC 服務開啟圖形化連接配接是非常必要

而且非常友善的。

francs推薦閱讀

繼續閱讀