VNC的安裝和常用命令


主要參考文章:http://www.cnblogs.com/coderzh/archive/2008/07/16/1243990.html 

                        http://os.51cto.com/art/201005/201136_all.htm 

                        http://blog.itpub.net/519536/viewspace-607549/

安裝:

1. 下載VNC文件,我使用的是:VNC-5.2.2-Linux-x64-RPM.tar.gz。去官網下載即可。

2. 解壓:tar -xzvf VNC-5.2.2-Linux-x64-RPM.tar.gz

3. 安裝:yum install VNC-Server-5.2.2-Linux-x64.rpm

    // 如果需要依賴某些程序,可以通過掛載印象,安裝常用開發軟件包解決

 添加license:vnclicense -add DNHA4-2H25M-Q5CSB-3J395-TTB8A       // 注意:必須是對應版本的license

4. 安裝完畢執行,vncserver 或 vncpasswd 命令設置用戶名和密碼 ;后續只能通過 vncpasswd 設置修改密碼

5. 某些 vnc 的圖形界面可能還需要配置文件才能顯示出來。如下:修改/root/.vnc/xstartup,

    把最后一行 twm& 改成 gnome-session& 或者 kde& (據說KDE在目前的VNC Viewer上的表現不太穩定)

6. 客戶端登陸 : 在vnc客戶端中輸入:服務器端IP:1 或 服務器端IP:5901 (后面的端口是根據server端的端口而定的)

7. 配置多個桌面,可以使用如下的方法啟動多個桌面的VNC

    vncserver :1

    vncserver :2

    vncserver :3

 

常用命令:

1. 啟動:vncserver(第一次推薦,可通過該命令設置密碼) 或 vncserver :1 (設置完密碼后推薦這種啟動,指定啟動端口)

2. 關閉命令 : vncserver -kill :1 ; vncserver -kill :2

3. 設置自啟動 : 配置VNC自動啟動。在/etc/sysconfig 下有一個 vncservers 的配置文件。修改成如下: VNCSERVERS="1:root" 意思就是使用ip:1即可使用root的

    用戶桌面。而在屏幕上不顯示。 使用chkconfig --level 3 vncserver 即可在啟動時加載vncserver

4. 設置完自啟動后,VNC的啟動/停止/重啟 : service vncserver start/stop/restart

    注意:3 和 4 未驗證,僅供參考

 

說明:

1. 設置的密碼會被加密保存在用戶主目錄下的.vnc子目錄(/root/.vnc/passwd)目錄中;同時在用戶主目錄下的.vnc子目錄中為用戶自動建立xstartup配置文件

  (/root/.vnc/xstartup),在每次啟動VND服務時,都會讀取該文件中的配置信息。

    /root/.vnc/目錄下還有一個“testdb:1.pid”文件,這個文件記錄着啟動VNC后對應后天操作系統的進程號,用於停止VNC服務時准確定位進程號。

    以上是常規的配置,我有次裝完后在上面目錄找不到,實際上xstartup在/etc/vnc目錄。可以通過locate搜索命名查找指定文件。

2. 若VNC非正常關閉,會導致當前非正常關閉的端口一直被占用(上面提到的.pid文件)。必須手動清楚相關文件,文件一般在/tmp 和 /tmp/.X11-unix/ 目錄中。

    例如:/tmp/.X1-lock 和 /tmp/.X11-unix/X1

    如果記不住,我們可以通過啟動命令:vncserver :1 ,指定啟動端口。報錯信息中會指明加鎖文件所在位置。

3. 運行vncserver可能會出現如下錯誤:

vncext: VNC extension running!
vncext: Listening for VNC connections on port 5901
vncext: Listening for HTTP connections on port 5801
vncext: created VNC server for screen 0
error opening security policy file /usr/X11R6/lib/X11/xserver/SecurityPolicy
Could not init font path element /usr/X11R6/lib/X11/fonts/misc/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/Speedo/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/Type1/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/CID/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/75dpi/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/100dpi/, removing from list!
Fatal server error:
could not open default font 'fixed'
xsetroot: unable to open display 'localhost.localdomain:1'
vncconfig: unable to open display "localhost.localdomain:1"
Warning: This program is an suid-root program or is being run by the root user.
The full text of the error or warning message cannot be safely formatted
in this environment. You may get a more descriptive message by running the
program as a non-root user or by removing the suid bit on the executable.
xterm Xt error: Can't open display: %s

      原因:vncserver默認尋找的X系統的字體路徑在/usr/X11R6/lib/X11/fonts/下,但RHEL5卻在/usr /share/X11/fonts/下

      解決:

             mkdir /usr/X11R6/lib    

             cd /usr/X11R6/lib

             ln -s /usr/share/X11 X11

 

推薦參考文章:http://blog.itpub.net/519536/viewspace-607549/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM