|
centos 6.8 VNC 搭建(详细)
背景:考虑有些情况下,需要用到图形化界面操作(如:配置KVM虚拟化),但是又不想去机房,针对这种情况,我们可以配置vnc服务,使得何时何处都可以轻松的办公(只要网络可达)
首先检查是否安装相应的软件包
redhat@opman ~]$ rpm -qa |grep tigervnc
[redhat@opman ~]$
[redhat@opman ~]$
没有,则安装!
yum -y install tigervnc
已加载插件:fastestmirror, refresh-packagekit, security
设置安装进程
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
再次检查是否安装上
[root@opman ~]# rpm -qa |grep tigervnc
tigervnc-1.1.0-24.el6.x86_64
tigervnc-server-1.1.0-24.el6.x86_64
启动vnc,首次会生成/root/.vnc/xstartup 文件,后面要配置相关参数
[root@opman ~]# vncserver
You will require a password to access your desktops.
Password:
Verify:
Passwords don't match - try again
Password:
Verify:
xauth: file /root/.Xauthority does not exist
New 'opman:1 (root)' desktop is opman:1
Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/opman:1.log
vim /root/.vnc/xstartup
#twm & //注释该行
gnome-session & //添加该行 如果为KDE桌面,则修改为:startkde &
启动服务,发现报错,需要修改配置文件
[root@opman ~]# /etc/init.d/vncserver start
正在启动 VNC 服务器:no displays configured [失败]
vim /etc/sysconfig/vncservers ;添加末尾3行;作用是设定vnc用户和对应界面的设置。我设置了两个用户分别是redhat 和root
最后启动vncserver 并设置为开机启动,执行以下
# service vncserver start
# chkconfig vncserver on
检查vnc服务的端口
[root@opman ~]# netstat -tunlp |grep vnc
tcp 0 0 0.0.0.0:5801 0.0.0.0:* LISTEN 3744/Xvnc
tcp 0 0 0.0.0.0:5802 0.0.0.0:* LISTEN 4481/Xvnc
tcp 0 0 0.0.0.0:5901 0.0.0.0:* LISTEN 3744/Xvnc
tcp 0 0 0.0.0.0:5902 0.0.0.0:* LISTEN 4481/Xvnc
tcp 0 0 0.0.0.0:6001 0.0.0.0:* LISTEN 3744/Xvnc
tcp 0 0 :::6001 :::* LISTEN 3744/Xvnc
查看vnc 进程
[root@opman ~]# ps -ef |grep vnc
root 3744 1 0 16:56 pts/0 00:00:00 /usr/bin/Xvnc :1 -desktop opman:1 (root) -httpd /usr/share/vnc/classes -auth /root/.Xauthority -geometry 1024x768 -rfbwait 30000 -rfbauth /root/.vnc/passwd -rfbport 5901 -fp catalogue:/etc/X11/fontpath.d -pn
root 3754 3753 0 16:56 pts/0 00:00:00 vncconfig -iconic
root 4481 1 0 17:09 pts/0 00:00:00 /usr/bin/Xvnc :2 -desktop opman:2 (root) -httpd /usr/share/vnc/classes -auth /root/.Xauthority -geometry 800x600 -depth 32 -rfbwait 30000 -rfbauth /root/.vnc/passwd -rfbport 5902 -fp catalogue:/etc/X11/fontpath.d -pn -nolisten tcp
root 4492 4490 0 17:09 pts/0 00:00:00 vncconfig -iconic
root 5090 4787 0 17:25 pts/0 00:00:00 grep vnc
用vncview 连接测试效果:
发现连接超时,在一切都正常的情况下,关闭防火墙。

service iptables stop
[root@opman .vnc]# service iptables stop
iptables:将链设置为政策 ACCEPT:nat mangle filter [确定]
iptables:清除防火墙规则: [确定]
iptables:正在卸载模块: [确定]
[root@opman .vnc]#
再次连接,ip+:2(ip + 端口)
|
|
|
|
|
|
|