一、安裝桌面環境
yumgroupinstalldesktop
二、安裝VNC服務
yum-yinstalltigervnc-server
修改配置文件
vi/etc/sysconfig/vncservers
#TheVNCSERVERSvariableisalistofdisplay:userpairs.
#
#UncommentthelinesbelowtostartaVNCserverondisplay:2
#asmy'myusername'(adjustthistoyourown).Youwillalso
#needtosetaVNCpassword;run'manvncpasswd'toseehow
#todothat.
#
#DONOTRUNTHISSERVICEifyourlocalareanetworkis
#untrusted!ForasecurewayofusingVNC,seethisURL:
#http://kbase.redhat.com/faq/docs/DOC-7028
#Use"-nolistentcp"topreventXconnectionstoyourVNCserverviaTCP.
#Use"-localhost"topreventremoteVNCclientsconnectingexceptwhen
#doingsothroughasecuretunnel.Seethe"-via"optioninthe
#`manvncviewer'manualpage.
#VNCSERVERS="2:myusername"
#VNCSERVERARGS[2]="-geometry800x600-nolistentcp-localhost"
VNCSERVERS="2:root"
VNCSERVERARGS[2]="-geometry1024×768-alwaysshared"
vi/root/.vnc/xstartup
#!/bin/sh
#Uncommentthefollowingtwolinesfornormaldesktop:
unsetSESSION_MANAGER
exec/etc/X11/xinit/xinitrc
[-x/etc/vnc/xstartup]&&exec/etc/vnc/xstartup
[-r$HOME/.Xresources]&&xrdb$HOME/.Xresources
xsetroot-solidgrey
vncconfig-iconic&
#xterm-geometry80x24+10+10-ls-title"$VNCDESKTOPDesktop"&
#twm&
gnome-session&
將這個xstartup文件的最後一行修改成「startkde&」,再從新啓動vncserver服務後就能夠登錄到KDE桌面環境
將這個xstartup文件的最後一行修改成「gnome-session&」,再從新啓動vncserver服務後就能夠登錄到GNOME桌面環境
從新啓動vncserver服務的方法:
vncserver-kill:1
vncserver:1
三、配置多個桌面
可使用以下的方法啓動多個桌面的VNC
vncserver:1
vncserver:2
vncserver:3
……
可是這種手工啓動的方法在服務器從新啓動以後將失效,所以,下面介紹如何讓系統自動管理多個桌面的VNC,方法是將須要自動管理的信息添加到/etc/sysconfig/vncservers配置文件中,先以桌面1爲root用戶桌面2爲oracle用戶爲例進行配置以下:
格式爲:VNCSERVERS="桌面號:使用的用戶名桌面號:使用的用戶名"
vi/etc/sysconfig/vncservers
VNCSERVERS="1:root2:oracle"
VNCSERVERARGS[1]="-geometry1024x768"
VNCSERVERARGS[2]="-geometry1024x768"
四、修改VNC訪問的密碼
使用命令vncpasswd對不一樣用戶的VNC的密碼進行修改,必定要注意,若是配置了不一樣用戶的VNC須要分別到各自用戶中進行修改,例如在個人這個實驗中,root用戶和oracle用戶須要分別修改,修改過程以下:
vncpasswd
Password:
Verify:
五、啓動和中止VNC服務
1)啓動VNC服務命令
/etc/init.d/vncserverstart
StartingVNCserver:1:root
New'testdb:1(root)'desktopistestdb:1
Startingapplicationsspecifiedin/root/.vnc/xstartup
Logfileis/root/.vnc/testdb:1.log
2:oracle
New'testdb:2(oracle)'desktopistestdb:2
Startingapplicationsspecifiedin/home/oracle/.vnc/xstartup
Logfileis/home/oracle/.vnc/testdb:2.log
[OK
2)中止VNC服務命令
/etc/init.d/vncserverstop
ShuttingdownVNCserver:1:root2:oracle[OK]
3)從新啓動VNC服務命令
/etc/init.d/vncserverrestart
ShuttingdownVNCserver:1:root2:oracle[OK]
StartingVNCserver:1:root
New'testdb:1(root)'desktopistestdb:1
Startingapplicationsspecifiedin/root/.vnc/xstartup
Logfileis/root/.vnc/testdb:1.log
2:oracle
New'testdb:2(oracle)'desktopistestdb:2
Startingapplicationsspecifiedin/home/oracle/.vnc/xstartup
Logfileis/home/oracle/.vnc/testdb:2.log[OK]
4)設置VNC服務隨系統啓動自動加載
第一種方法:使用「ntsysv」命令啓動圖形化服務配置程序,在vncserver服務前加上星號,點擊肯定,配置完成。
第二種方法:使用「chkconfig」在命令行模式下進行操做,命令使用以下(預知chkconfig詳細使用方法請自助式man一下)
chkconfigvncserveron
chkconfig--listvncserver
vncserver0:off1:off2:on3:on4:on5:on6:off