centos 6.5 配置安装vnc

环境:

OS:Centos 6.5

 

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

 

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


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.设置屏幕保护
System -> Preferences -> Screensaver。
如果需要取消屏幕保护的锁定功能,将Lock screen when screensaver is active前面的勾去掉就可以了

 

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

192.168.56.66:1

 

问题

启动报错误:
[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
原文地址:https://www.cnblogs.com/hxlasky/p/15606181.html