VNC_Linux环境服务安装、配置与使用
linu下載頁(yè)面:
http://www.realvnc.com/products/download.html
http://www.onlinedown.net/soft/45175.htm
win下VNC Viewer 下載(包括注冊(cè)碼在內(nèi)): http://xok.la/file/2008/11/ha_vnc-e4_2_9-x86_win32.rar
1.確認(rèn)VNC是否安裝
默認(rèn)情況下,Red Hat Enterprise Linux安裝程序會(huì)將VNC服務(wù)安裝在系統(tǒng)上。
確認(rèn)是否已經(jīng)安裝VNC服務(wù)及查看安裝的VNC版本
[root@testdb ~]# rpm -q vnc-server
yum -y install tigervnc-server
vnc-server-4.1.2-9.el5
[root@testdb ~]#
若系統(tǒng)沒有安裝,可以到操作系統(tǒng)安裝盤的Server目錄下找到VNC服務(wù)的RPM安裝包vnc-server-4.1.2-9.el5.x86_64.rpm,安裝命令如下
rpm -ivh /mnt/Server/vnc-server-4.1.2-9.el5.x86_64.rpm
2.啟動(dòng)VNC服務(wù)
使用vncserver命令啟動(dòng)VNC服務(wù),命令格式為“vncserver :桌面號(hào)”,其中“桌面號(hào)”用“數(shù)字”的方式表示,每個(gè)用戶連個(gè)需要占用1個(gè)桌面
啟動(dòng)編號(hào)為1的桌面示例如下
[root@testdb ~]# vncserver :1
You will require a password to access your desktops.
Password:
Verify:
xauth: creating new authority file /root/.Xauthority
New 'testdb:1 (root)' desktop is testdb:1
Creating default startup script. /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/testdb:1.log
以上命令執(zhí)行的過程中,因?yàn)槭堑谝淮螆?zhí)行,需要輸入密碼,這個(gè)密碼被加密保存在用戶主目錄下的.vnc子目錄(/root/.vnc/passwd)中;同時(shí)在用戶主目錄下的.vnc子目錄中為用戶自動(dòng)建立xstartup配置文件(/root/.vnc/xstartup),在每次啟動(dòng)VND服務(wù)時(shí),都會(huì)讀取該文件中的配置信息。
BTW:/root/.vnc/目錄下還有一個(gè)“testdb:1.pid”文件,這個(gè)文件記錄著啟動(dòng)VNC后對(duì)應(yīng)后天操作系統(tǒng)的進(jìn)程號(hào),用于停止VNC服務(wù)時(shí)準(zhǔn)確定位進(jìn)程號(hào)。
3.VNC服務(wù)使用的端口號(hào)與桌面號(hào)的關(guān)系
VNC服務(wù)使用的端口號(hào)與桌面號(hào)相關(guān),VNC使用TCP端口從5900開始,對(duì)應(yīng)關(guān)系如下
桌面號(hào)為“1” ---- 端口號(hào)為5901
桌面號(hào)為“2” ---- 端口號(hào)為5902
桌面號(hào)為“3” ---- 端口號(hào)為5903
……
基于Java的VNC客戶程序Web服務(wù)TCP端口從5800開始,也是與桌面號(hào)相關(guān),對(duì)應(yīng)關(guān)系如下
桌面號(hào)為“1” ---- 端口號(hào)為5801
桌面號(hào)為“2” ---- 端口號(hào)為5802
桌面號(hào)為“3” ---- 端口號(hào)為5803
……
基于上面的介紹,如果Linux開啟了防火墻功能,就需要手工開啟相應(yīng)的端口,以開啟桌面號(hào)為“1”相應(yīng)的端口為例,命令如下
[root@testdb ~]# iptables -I INPUT -p tcp --dport 5901 -j ACCEPT
[root@testdb ~]# iptables -I INPUT -p tcp --dport 5801 -j ACCEPT
4.測(cè)試VNC服務(wù)
第一種方法是使用VNC Viewer軟件登陸測(cè)試,操作流程如下
啟動(dòng)VNC Viewer軟件 --> Server輸入“144.194.192.183:1” --> 點(diǎn)擊“OK” --> Password輸入登陸密碼 --> 點(diǎn)擊“OK”登陸到X-Window圖形桌面環(huán)境 --> 測(cè)試成功
第二種方法是使用Web瀏覽器(如Firefox,IE,Safari)登陸測(cè)試,操作流程如下
地址欄輸入http://144.194.192.183:5801/ -->
出現(xiàn)VNC viewer for Java(此工具是使用Java編寫的VNC客戶端程序)界面,同時(shí)跳出VNC viewer對(duì)話框,在Server處輸入“144.194.192.183:1”
點(diǎn)擊“OK” --> Password輸入登陸密碼 --> 點(diǎn)擊“OK”登陸到X-Window圖形桌面環(huán)境 --> 測(cè)試成功
(注:VNC viewer for Java需要JRE支持,如果頁(yè)面無法顯示,表示沒有安裝JRE,可以到
http://java.sun.com/javase/downloads/index_jdk5.jsp這里下載最新的JRE進(jìn)行安裝)
5.配置VNC圖形桌面環(huán)境為KDE或GNOME桌面環(huán)境
如果您是按照我的上面方法進(jìn)行的配置的,登陸到桌面后效果是非常簡(jiǎn)單的,只有一個(gè)Shell可供使用,這是為什么呢?怎么才能看到可愛并且美麗的KDE或GNOME桌面環(huán)境呢?回答如下
之所以那么的難看,是因?yàn)閂NC服務(wù)默認(rèn)使用的是twm圖形桌面環(huán)境的,可以在VNC的配置文件xstartup中對(duì)其進(jìn)行修改,先看一下這個(gè)配置文件
[root@testdb ~]# cat /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 &
將 # unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
前面注釋去掉
或者
將這個(gè)xstartup文件的最后一行修改為“startkde &”,再重新啟動(dòng)vncserver服務(wù)后就可以登陸到KDE桌面環(huán)境
或者
將這個(gè)xstartup文件的最后一行修改為“gnome-session &”,再重新啟動(dòng)vncserver服務(wù)后就可以登陸到GNOME桌面環(huán)境
重新啟動(dòng)vncserver服務(wù)的方法:
[root@testdb ~]# vncserver -kill :1
[root@testdb ~]# vncserver :1
6.配置多個(gè)桌面
可以使用如下的方法啟動(dòng)多個(gè)桌面的VNC
vncserver :1
vncserver :2
vncserver :3
……
但是這種手工啟動(dòng)的方法在服務(wù)器重新啟動(dòng)之后將失效,因此,下面介紹如何讓系統(tǒng)自動(dòng)管理多個(gè)桌面的VNC,方法是將需要自動(dòng)管理的信息添加到/etc/sysconfig/vncservers配置文件中,先以桌面1為root用戶桌面2為oracle用戶為例進(jìn)行配置如下:
格式為:VNCSERVERS="桌面號(hào):使用的用戶名 桌面號(hào):使用的用戶名"
[root@testdb ~]# vi /etc/sysconfig/vncservers
VNCSERVERS="1:root 2:oracle"
VNCSERVERARGS[1]="-geometry 1024x768"
VNCSERVERARGS[2]="-geometry 1024x768"
7.修改VNC訪問的密碼
使用命令vncpasswd對(duì)不同用戶的VNC的密碼進(jìn)行修改,一定要注意,如果配置了不同用戶的VNC需要分別到各自用戶中進(jìn)行修改,例如在我的這個(gè)實(shí)驗(yàn)中,root用戶和oracle用戶需要分別修改,修改過程如下:
[root@testdb ~]# vncpasswd
Password:
Verify:
[root@testdb ~]#
8.啟動(dòng)和停止VNC服務(wù)
1)啟動(dòng)VNC服務(wù)命令[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服務(wù)命令
[root@testdb ~]# /etc/init.d/vncserver stop
Shutting down VNC server: 1:root 2:oracle [ OK ]
3)重新啟動(dòng)VNC服務(wù)命令
[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)設(shè)置VNC服務(wù)隨系統(tǒng)啟動(dòng)自動(dòng)加載
第一種方法:使用“ntsysv”命令啟動(dòng)圖形化服務(wù)配置程序,在vncserver服務(wù)前加上星號(hào),點(diǎn)擊確定,配置完成。
第二種方法:使用“chkconfig”在命令行模式下進(jìn)行操作,命令使用如下(預(yù)知chkconfig詳細(xì)使用方法請(qǐng)自助式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
VNC 服務(wù)器/本地復(fù)制粘貼實(shí)現(xiàn)命令
[root@~]#vncconfig -nowin&
######################################################################
centos 黑屏
查看日志 ~/.vnc/localhost.localdomain:0.log
/home/cake/.vnc/xstartup: line 27: xsetroot: command not found
/home/cake/.vnc/xstartup: line 28: xterm: command not found
/home/cake/.vnc/xstartup: line 29: twm: command not found
XIO: fatal IO error 11 (Resource temporarily unavailable) on X server “:0″^M
after 141 requests (140 known processed) with 0 events remaining.^M
因?yàn)閤setroot/xterm/twm沒有安裝導(dǎo)致的。
于是使用yum安裝:
yum install xsetroot
yum install xterm
yum install twm
kill掉vncserver進(jìn)程,然后重新啟動(dòng)。
vncserver -kill :1
vncserver :1
轉(zhuǎn)載于:https://blog.51cto.com/zhangguangjun/2047209
總結(jié)
以上是生活随笔為你收集整理的VNC_Linux环境服务安装、配置与使用的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: MATLAB指纹识别文献综述
- 下一篇: 深度剖析JAVA软件工程师