CentOS 6.3安装和配置VNC

CentOS 6.3安装和配置VNC
       原文作者:阿飞。 十分感谢
       对于用惯了WIN系统的朋友来说,没有图形化操作界面的Linux用起来实在太难受了。实际上,Linux也是有图形化操作界面的,这就是VNC。接下来罗伊将告诉大家如何 VNC图形化操作界面。

1,安装GNOME桌面环境

[root@tanvps ~]# yum -y groupinstall “GNOME Desktop Environment”

2, 安装KDE桌面环境

[root@tanvps ~]# yum groupinstall “X Window System” “KDE (K Desktop Environment)”

3,安装VNC服务器

[root@tanvps ~]# yum -y install vnc-server
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirror-fpt-telecom.fpt.net
* extras: mirror-fpt-telecom.fpt.net
* updates: mirror-fpt-telecom.fpt.net
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package tigervnc-server.i686 0:1.0.90-0.17.20110314svn4359.el6 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

================================================== ==============================
Package Arch Version Repository
Size
================================================== ==============================
Installing:
tigervnc-server i686 1.0.90-0.17.20110314svn4359.el6 base 1.1 M

Transaction Summary
================================================== ==============================
Install 1 Package(s)

Total download size: 1.1 M
Installed size: 2.9 M
Downloading Packages:
tigervnc-server-1.0.90-0.17.20110314svn4359.el6.i686.rpm | 1.1 MB 00:02
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Importing GPG key 0xC105B9DE:
Userid : CentOS-6 Key (CentOS 6 Official Signing Key)

Installed:
tigervnc-server.i686 0:1.0.90-0.17.20110314svn4359.el6

Complete!
[root@tanvps ~]#

4,配置VNC

[root@tanvps ~]# su -jackiebui
[jackiebui@tanvps ~]# vncpasswd
Password:******
verify:******
[jackiebui@tanvps ~]# ls .vnc/

5,编辑VNC配置文件

[root@tanvps ~]# vi /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:
# http://kbase.redhat.com/faq/docs/DOC-7028

# 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=”1:jackiebui” //Uncomment 2 last lines, and edit your VNC user
VNCSERVERARGS[2]=”-geometry 800×600 -nolisten tcp -localhost” // Save and exit

启动VNC

[root@tanvps ~]# vncserver
[root@tanvps ~]# chkconfig vncserver on //设置为开机启动


安装以下包解决字体问题:

yum install libXfont xorg-x11-xinit xorg-x11-fonts-Type1 




修改默认分辨率大小:

1.第一种方法:使用geometry参数进行调整
使用man命令获得关于geometry参数的描述
[root@secdb ~]# man vncserver
……
       -geometry widthxheight
              Specify the size of the desktop to be created. Default is 1024x768.
……


可见,默认的分辨率是1024x768,我们可以使用这个参数对分辨率进行调整。
例如,我们需要将分辨率调整到800x600
[root@secdb ~]# vncserver -geometry 800x600

New 'secdb:5 (root)' desktop is secdb:5

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/secdb:5.log

此时使用“192.168.23.102:5”登录VNC便会得到一个800x600的操作窗口。
其他分辨率调整请自行尝试。

2.第二种方法:修改配置文件vncservers
[root@secdb ~]# vi /etc/sysconfig/vncservers
# The VNCSERVERS variable is a list of display:user pairs.
#
# Uncomment the line below to start a VNC server on display :1
# 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/vnc/sshvnc.html>.

# VNCSERVERS="1:myusername"
# VNCSERVERARGS[1]="-geometry 800x600"
VNCSERVERS="1:root 2:oracle"
VNCSERVERARGS[1]="-geometry 1024x768"
VNCSERVERARGS[2]="-geometry 1024x768"

例如我们可以将最后一行内容调整为如下
VNCSERVERARGS[2]="-geometry 800x600"

重启vncserver后,使用“192.168.23.102:2”登录VNC便会得到一个800x600的操作窗口,用户是oracle。
[root@secdb ~]# /etc/init.d/vncserver restart
Shutting down VNC server: 1:root 2:oracle              [  OK  ]
Starting VNC server: 1:root 2:oracle                   [  OK  ]

3.小结
两种修改方法各有利弊,请根据具体环境进行调整。使用第一种方法操作简单,影响范围小,因为该方法是通过单独启动vnc进程来提供服务的,但是容易在系统中遗留过多的vnc进程;第二种方法是通过调整VNC默认分辨率的手段实现的,实现集中管理,但存在因分辨率调整过高导致客户端无法使用的问题。

Good luck.

secooler
10.07.20

-- The End --






评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值