centos 6.5 配置安装vnc

环境:

OS:Centos 6.5/6.9

 

1.安装桌面包(选择桌面安装的话,已经安装)
yum -y groupinstall Desktop
yum -y groupinstall "X Window System"

 

2.设置图形界面启动(需要重新启动)
/etc/inittab
修改为5 图形界面启动
id:5:initdefault:

或是不设置也可以通过startx启动图形界面

 

3.安装图形界面右键出现打开终端栏目
[root@newepidb ios]# mount CentOS-6.5-x86_64-bin-DVD1.iso -o loop /mnt
[root@newepidb ios]#yum -y install nautilus-open-terminal

 


安装vnc
1.检查是否已经安装了vnc-server
[root@newepidb ios]# rpm -q tigervnc tigervnc-server
package tigervnc is not installed
package tigervnc-server is not installed

 

2.安装vnc-server
yum install tigervnc-server

3.配置vnc-server

打开配置文件目录并编辑配置文件


[root@VM_0_11_centos ~]# vi /etc/sysconfig/vncservers[root@rac01 u01]# more /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:
# https://access.redhat.com/knowledge/solutions/7027

# 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="2:root 1:oracle 3:grid"
##VNCSERVERARGS[1]="-geometry 800x600 -nolisten tcp -localhost"
VNCSERVERSVNCSERVERARGS[1]="-geometry 1024x768 -alwaysshared"
VNCSERVERSVNCSERVERARGS[2]="-geometry 1024x768 -alwaysshared"
VNCSERVERSVNCSERVERARGS[3]="-geometry 1024x768 -alwaysshared"
复制代码

 

 

 

 

 

4.输入命令启动vnc服务(root访问密码)
初始启动时需要配置远程用户连接vnc时输入的密码
[root@newepidb ios]# vncserver

You will require a password to access your desktops.

Password:
Verify:
xauth: (stdin):1: bad display name "newepidb:1" in "add" command

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

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

 

5.修改vnc远程连接的密码(oracle访问密码,可以与root设置的密码不一样)
su - oracle
[oracle@newepidb ~]$ vncpasswd
Password:
Verify:

 

su - grid
[oracle@newepidb ~]$ vncpasswd
Password:
Verify: 

 

 

6.重启动vncserver

杀掉之前启动的进程

vncserver -kill :1 ##kill与:之间有空格
vncserver -kill :2 ##kill与:之间有空格

service vncserver stop
service vncserver start

 


7.查看
[root@newepidb ios]# vncserver -list

TigerVNC server sessions:

X DISPLAY # PROCESS ID
:1 2536

我在centos6.9上安装该命令没有显示也可以正常使用

 

查看端口是否打开

[root@rac01 u01]# ss -nlp|grep 5901
LISTEN 0 5 *:5901 *:* users:(("Xvnc",5151,5))

 


8.关闭防火墙
[root@newepidb ios]#service iptables stop --命令关闭防火墙,但是系统重启后会开始
[root@newepidb ios]#chkconfig iptables off --关闭防火墙开机自启动
[root@newepidb ios]#chkconfig --list --查看开机情况


9.日常命令
service vncserver status
service vncserver restart
service vncserver stop
service vncserver start

vncserver -kill :1 ##kill与:之间有空格
vncserver -kill :2 ##kill与:之间有空格

9.设置屏幕保护(非root账号也可以设置)
System -> Preferences -> Screensaver。
如果需要取消屏幕保护的锁定功能,将Lock screen when screensaver is active前面的勾去掉就可以了

 

10.通过vnc :1进行连接(oracle账号)

192.168.56.66:1

 

grid账号

 192.168.56.66:3

 

问题

复制代码
启动报错误:
[root@epidbhn ~]# service vncserver start
Starting VNC server: 2:root xauth: (stdin):1:  bad display name "epidbhn:2" in "add" command

New 'epidbhn:2 (root)' desktop is epidbhn:2

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/epidbhn:2.log

1:oracle 
Warning: epidbhn:1 is taken because of /tmp/.X11-unix/X1
Remove this file if there is no X server epidbhn:1
A VNC server is already running as :1
                                                           [FAILED]
[root@epidbhn ~]# ps -ef|grep vnc
root     11884     1  1 11:30 pts/1    00:00:00 /usr/bin/Xvnc :2 -desktop epidbhn:2 (root) -auth /root/.Xauthority -geometry 1024x768 -rfbwait 30000 -rfbauth /root/.vnc/passwd -rfbport 5902 -fp catalogue:/etc/X11/fontpath.d -pn
root     11891 11889  0 11:30 pts/1    00:00:00 vncconfig -iconic
root     12067  7716  0 11:30 pts/1    00:00:00 grep vnc
[root@epidbhn ~]# vncserver -kill :2
Killing Xvnc process ID 11884
[root@epidbhn ~]# vncserver -kill :1

Can't find file /root/.vnc/epidbhn:1.pid
You'll have to kill the Xvnc process manually

解决办法:
[root@epidbhn ~]# cd /tmp/.X11-unix/X1
-bash: cd: /tmp/.X11-unix/X1: Not a directory
[root@epidbhn ~]# rm -rf /tmp/.X11-unix
[root@epidbhn ~]# 
[root@epidbhn ~]# 
[root@epidbhn ~]# service vncserver status
Xvnc is stopped
[root@epidbhn ~]# service vncserver start
Starting VNC server: 2:root xauth: (stdin):1:  bad display name "epidbhn:2" in "add" command

New 'epidbhn:2 (root)' desktop is epidbhn:2

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/epidbhn:2.log

1:oracle xauth: (stdin):1:  bad display name "epidbhn:1" in "add" command

New 'epidbhn:1 (oracle)' desktop is epidbhn:1

Creating default startup script /home/oracle/.vnc/xstartup
Starting applications specified in /home/oracle/.vnc/xstartup
Log file is /home/oracle/.vnc/epidbhn:1.log
复制代码

 

posted @   slnngk  阅读(216)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示