過一段時間就要安裝,我寫這裏複製方便些。vim
1 查詢是否安裝了vncbash
#rpm -qa |grep vnc
2 能夠在yum 源上查看vnc軟件服務器
#yum list |grep vnc tigervnc.x86_64 1.1.0-24.el6 @os tigervnc-server.x86_64 1.1.0-24.el6 @os
3 安裝tigervnc軟件session
#yum install -y tigervnc #yum install -y tigervnc-server
4 配置vnc服務器文件oracle
vim /etc/sysconfig/vncservers
在文件後面添加以下內容:app
VNCSERVERS="1:root 2:oracle" VNCSERVERARGS[1]="-geometry 1920x1080 -depth 32 -nolisten tcp" VNCSERVERARGS[2]="-geometry 1920x1080 -depth 32 -nolisten tcp"
解釋:這裏開啓了2個vnc桌面,1號爲root的,2號爲oracle的,在這裏配置的都必須是已有的用戶.
下面的參數 就是分辨率,顏色深度,綁定ip等。tcp
這裏是vncservers文件: #cat /etc/sysconfig/vncservers測試
# The VNCSERVERS variable is a list of display:user pairs. # # Uncomment the lines below to start a VNC server on display :2 # as my 'myusername' (adjust this to your own). You will also # need to set a VNC password; run 'man vncpasswd' to see how # to do that. # # DO NOT RUN THIS SERVICE if your local area network is # untrusted! For a secure way of using VNC, see this URL: # https://access.redhat.com/knowledge/solutions/7027 # Use "-nolisten tcp" to prevent X connections to your VNC server via TCP. # Use "-localhost" to prevent remote VNC clients connecting except when # doing so through a secure tunnel. See the "-via" option in the # `man vncviewer' manual page. # VNCSERVERS="2:myusername" (最多能夠6個用戶) # VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -localhost" VNCSERVERS="1:root 2:oracle" VNCSERVERARGS[1]="-geometry 1920x1080 -depth 32 -nolisten tcp" VNCSERVERARGS[2]="-geometry 1920x1080 -depth 32 -nolisten tcp"
5 使用root執行vncserver 會提示先輸入密碼,這個密碼vnc的連接密碼this
則還會有
Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
提示code
咱們這裏還配置了oracle用戶的,咱們還須要切換到oracle用戶,而後執行vncpasswd,爲2號vnc的oracle用戶生成vnc的連接密碼
注:固然root下,也是隻執行vncpasswd生成密碼的,
而後統一執行service vncserver start。這樣都一樣會爲root,和oracle用戶在他們的家目錄生成 .vnc/xstartup文件。
6 修改 .vnc/xstartup文件(多個用戶都須要修改,若是某個用戶沒有這個文件則是須要在改用戶下啓動一下vncserver ,或者 vncserver :2, 或者利用 service vncserver start這樣都會爲用戶建立默認的xstartup文件)
若是是gnome桌面,則把twm & 註釋掉,添加gnome-session &
若是是KDE桌面,則把twm & 註釋掉,添加startkde &
這裏是xstartup文件: #cat .vnc/xstartup
#!/bin/sh [ -r /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n export LANG export SYSFONT vncconfig -iconic & unset SESSION_MANAGER unset DBUS_SESSION_BUS_ADDRESS OS=`uname -s` if [ $OS = 'Linux' ]; then case "$WINDOWMANAGER" in *gnome*) if [ -e /etc/SuSE-release ]; then PATH=$PATH:/opt/gnome/bin export PATH fi ;; esac fi if [ -x /etc/X11/xinit/xinitrc ]; then exec /etc/X11/xinit/xinitrc fi if [ -f /etc/X11/xinit/xinitrc ]; then exec sh /etc/X11/xinit/xinitrc fi [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources xsetroot -solid grey xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" & #twm & gnome-session &
7 啓動vncserver
service vncserver start vncserver :1 vncserver -kill:1
vncserver -kill :桌面號 #關閉某個桌面號
vncserver :桌面號 #啓動某個桌面號
8 添加開機啓動和測試
chkconfig vncserver on
chkconfig vncserver --list
防火牆
service iptables status
添加允許經過的規則,或者直接關閉iptables,若是是添加規則別忘了 service iptables save保存下。
在測試有的是輸入ip:加5901,5902這個端口,有的則是ip:1,ip:2這個vnc這個序號,也有由於vnc版本問題連接不成功的。