vnc 配置和调试

需要配置两个文件
1./etc/sysconfig/vncusers

 
 
# 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
# <URL:http://www.uk.research.att.com/archive/vnc/sshvnc.html>.
 
# Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.
 
# Use "-nohttpd" to prevent web-based VNC clients connecting.
 
# 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"
# VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd -localhost"
# --指定远程用户
VNCSERVERS="1:root"   
#    --指定远程桌面分辨率
VNCSERVERARGS[1]="-geometry 1024x768"  

2.修改完vncusers文件后在命令行中运行vncpasswd命令,会提示输入密码和确认密码,输入完成后会在/root/.vnc/目录下生成passwd文件。

3.
/root/.vnc/xstartup
如果是第一次启动vnc,这个文件是不存在的,所以需要首先启动一遍服务器,命令:service vncserver start,之后进入/root/.vnc/目录,就能看到。
#!/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 & 
 
修改完这个文件后运行service vncserver restart,如果出现关闭服务失败的情况,在重复运行一般重启命令即可。如果找不到vncserver这个服务,运行vncserver -kill :1 其中1为第一个运行的vncserver进程。
 
4.使用vnc viewer,打开后输入ip:1,然后点击“确定”按钮后,输入刚才运行vncpasswd命令后,就能打开远程桌面了。
5.如果出现黑屏的错误,可以看一下/root/.vnc/localhost.localdomain:1.log文件,里面有日志信息。
常见的错误不关乎有两点。第一,连接后出现的桌面是一个个的小方块,鼠标单击后出现类似于右键菜单的界面,桌面上除了一个shell窗口外什么也看不到。这时候修改一下/etc/sysconfig/vncusers中的
VNCSERVERARGS[1]="-geometry 1024x768"  
这句话,如果原来是1024X768,那么改成800X600试试。
第二,如果出现了正常的界面,但是鼠标不能打击任何东西;或者鼠标能点击桌面图标但是点击一下任务栏上的系统菜单立马卡死。这时候修改一下/etc/inittab文件,
id:5:initdefault:
修改为
id:3:initdefault:
然后重启一下电脑。
 
如果是suse系统,处理方法跟上述稍有不同,可以参考http://www.swerdna.net.au/susetightvnc.html
6.如果感觉分辨率太小,可以在启动的时候加上分辨率参数,即运行vncserver -geometry 800x600,即可指定当前的分辨率为800*600
 

猜你喜欢

转载自yunnysunny.iteye.com/blog/1423975
VNC