vnc server安装配置

  • Post author:
  • Post category:其他


1.查询是否安装vnc server

[root@dbserver ~]# rpm -q vnc-server
vnc-server-4.1.2-14.el5_6.6        --出现此信息则表示已安装,否则未安装

2.安装vnc server

[root@dbserver ~]# rpm –ivh vnc-server-4.1.2-14.el5_6.6.x86_64.rpm

3.配置文件(添加用户)

--添加以下几行,保存并退出
[root@dbserver ~]# vi /etc/sysconfig/vncservers
………………………………
VNCSERVERS="1:root  2:oracle"
VNCSERVERARGS[1]="-geometry 1024x768 -alwaysshared"
VNCSERVERARGS[2]="-geometry 1024x768 -alwaysshared"

4.逐个用户运行vncserver

逐个用户运行vncserver,它将完成两项工作:
--为用户创建所需.vnc 文件夹;
--用户设置登录密码 (如需要修改密码用vncpasswd);

--1.root用户运行vncserver
[root@dbserver ~]# vncserver

You will require a password to access your desktops.

Password:                            //输入密码
Verify:                              //再次输入密码
xauth:  creating new authority file /root/.Xauthority

New 'dbserver:1 (root)' desktop is dbserver:1

Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/dbserver:1.log

--2.编辑.vnc/xstartup
[root@dbserver ~]# cd .vnc
[root@dbserver .vnc]# vi 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
注释掉:
  twm &
添加行:
  gnome-session &

--3.配置完成后如下:
[root@dbserver .vnc]# vi 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 &

gnome-session &
~                                                                               
~                                                                               
~                                                                                                                                                           
"xstartup" 14L, 350C

--4.oracle用户运行vncserver
oracle用户执行一遍上述root用户的操作,如下:
[oracle@dbserver ~]$ vncserver

You will require a password to access your desktops.

Password:
Verify:
xauth:  creating new authority file /u01/app/oracle/.Xauthority

New 'dbserver:2 (oracle)' desktop is dbserver:2

Creating default startup script /u01/app/oracle/.vnc/xstartup
Starting applications specified in /u01/app/oracle/.vnc/xstartup
Log file is /u01/app/oracle/.vnc/dbserver:2.log

[oracle@dbserver ~]$ cd /u01/app/oracle/.vnc/
[oracle@dbserver .vnc]$ vi 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 &

修改后如下:
#!/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 &

gnome-session &
~   

--5.若还有其它用户,对每个需要使用远程桌面的用户都使用上述方法进行修改。

5.完成配置后的操作

--以上配置完成后,登陆vnc,客户端看到的仍有可能只是命令行界面,非图形化操作界面,这时只要以root用户重启vncserver即可。
[root@dbserver ~]# service vncserver stop     --关闭服务
Shutting down VNC server: 1:root 2:oracle                  [  OK  ]
[root@dbserver ~]# service vncserver start    --重启服务
Starting VNC server: 1:root 
New 'dbserver:1 (root)' desktop is dbserver:1

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/dbserver:1.log

2:oracle 
New 'dbserver:2 (oracle)' desktop is dbserver:2

Starting applications specified in /u01/app/oracle/.vnc/xstartup
Log file is /u01/app/oracle/.vnc/dbserver:2.log

                                                          [  OK  ]

--用此命令检查vnc是否开启:
[oracle@dbserver ~]$ vncserver :2
A VNC server is already running as :2

6.vnc其它相关命令

--vncserver启动及停止
启动# service vncserver start
停止# service vncserver stop

--强制关闭VNC SERVER服务
[root@localhost ~]# vncserver -kill :1 (kill和:1之间有一个空格)
Killing Xvnc process ID 21198



版权声明:本文为snowYing97原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。