chinaab 发表于 2019-2-15 16:25:33

centos 6.8 VNC 搭建(详细)

  centos 6.8 VNC 搭建(详细)
  背景:考虑有些情况下,需要用到图形化界面操作(如:配置KVM虚拟化),但是又不想去机房,针对这种情况,我们可以配置vnc服务,使得何时何处都可以轻松的办公(只要网络可达)
  首先检查是否安装相应的软件包
  redhat@opman ~]$ rpm -qa |grep tigervnc
  $
  $
  没有,则安装!
  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
  再次检查是否安装上
  # 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 文件,后面要配置相关参数
  # 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 &
  启动服务,发现报错,需要修改配置文件
  # /etc/init.d/vncserverstart
  正在启动 VNC 服务器:no displays configured                [失败]
  vim   /etc/sysconfig/vncservers ;添加末尾3行;作用是设定vnc用户和对应界面的设置。我设置了两个用户分别是redhat 和root
http://s1.运维网.com/images/20181024/1540376123884880.png
最后启动vncserver 并设置为开机启动,执行以下
# service vncserver start
# chkconfig vncserver on
  检查vnc服务的端口
  # 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 进程
  #ps -ef |grep vnc
  root       3744      10 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   37530 16:56 pts/0    00:00:00 vncconfig -iconic
  root       4481      10 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   44900 17:09 pts/0    00:00:00 vncconfig -iconic
  root       5090   47870 17:25 pts/0    00:00:00 grep vnc
  用vncview 连接测试效果:
  发现连接超时,在一切都正常的情况下,关闭防火墙。
  http://s1.运维网.com/images/20181024/1540376315822879.png
  service iptables stop
  # service iptables stop
  iptables:将链设置为政策 ACCEPT:nat mangle filter         [确定]
  iptables:清除防火墙规则:                                 [确定]
  iptables:正在卸载模块:                                 [确定]
  #
  再次连接,ip+:2(ip + 端口)
http://s1.运维网.com/images/20181024/1540376437195089.png
http://s1.运维网.com/images/20181024/1540376444238805.png
http://blog.运维网.com/static/js/ueditor1.4.3/themes/default/images/spacer.gif
http://blog.运维网.com/static/js/ueditor1.4.3/themes/default/images/spacer.gif



页: [1]
查看完整版本: centos 6.8 VNC 搭建(详细)