今天裝了下VNC,解決了不少問題,寫個教學貼,給新手們看看,如果你們碰到同樣的問題,就可以迅速解決,無需頭疼甚至放棄了。
系統內容
VM+RHEL5.1
[root@localhost .vnc]# uname -r
2.6.18-53.el5xen
本地XP系統安裝VNCVIEW去控制VM中的RHEL5.1
下面在LINUX上安裝VNCSERVER
1、去http://www.realvnc.com/去下載免費版for x86 linux
2、下載是一個tar.gz檔案,解壓後進入檔案夾,裡面有個README,請注意這塊不要下載RPM包,依賴問題以及包頭的安全簽名會讓你很鬱悶的。
3、解壓縮,進入該檔案夾,按照readme 要求執行4步
% ./vncinstall /usr/local/bin
% ./vncinstall /usr/local/bin /usr/local/man
% mkdir -p /usr/local/vnc/classes
% cp java/* /usr/local/vnc/classes
4、啟動VNCSERVER,輸入串連密碼
5、可能會提示linux1x: error while loading shared libraries: libstdc++-libc6.2-2.so.3: cannot open shared object file: No such file or directory
去下載libstdc++-libc6.2-2.so.3,放到/usr/lib裡面, (這個我碰到了,通過下載這個SO檔案解決了)
下面這個方法在這個版本中不可取,我已經試過,是無效的
在我的系統上ls命令的結果是 libstdc++.so.5.0.7 libstdc++.so.6.0.8
libstdc++.so.6.0.8就是我們要找的,給它做個連結
代碼:
$ sudo ln -s libstdc++.so.6.0.8 libstdc++-libc6.2-2.so.3
會出現如下錯誤:
vncpasswd: symbol lookup error:vncpasswd: undefined symbol: __builtin_vec_new
看到這個錯感覺就是那兩個庫不一樣造成的字元未定義
6、繼續啟動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
7、在XP上啟用vncview,注意,這個裡面填寫的IP地址加案頭號,一般是1,但是如果有多人登入案頭可能就不是1,需要詢問管理員,如下格式:192.168.1.102:1
[root@localhost ~]# netstat -an |grep 01
tcp 0 0 0.0.0.0:5801 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:5901 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:6001 0.0.0.0:* LISTEN
8 、VNC串連成功後,發現只有TWM介面,不是傳說中的案頭,修改如下
去掉中以下兩行前面的#號,讓vnc載入預設圖形介面程式
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
這兩行可能有些檔案中沒有,需要手動添加,沒有是顯示不了案頭的
修改下面這個東西
把最後一行 twm& 改成------->gonme-session &
附:我的設定檔
#!/bin/sh
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
gnome-session &
~
9、記錄檔中的錯誤
記錄檔位置在root主目錄下的隱藏檔案 /root/.vnc/localhost.localdomain:1.log 或者是2.log上,這個1和2的區別就是案頭號了,不同的案頭號對應的不同的LOG檔案
error opening security policy file /usr/X11R6/lib/X11/xserver/SecurityPolicy
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/CID/, removing from list!
這個幾個錯誤一直存在,但是目前沒有發現VNC正常運行。請大俠們指點指點。
BTW:一般案頭號啟動都是1,可以通過命令來控制vncserver :10 那這樣案頭號就變成10,登入的時候就是XX.XX.XX.XX:10就OK了
10、把VNC加入服務,每次啟動自動開啟
這個就不用說了,chkconfig add即可。