操作系统:Centos6.9(64Bit)
Oracle:11g 、11.2.0.4.0版本
Ip地址:172.16.220.139
废话不多说了,下面记录安装过程:
1)安装桌面环境
[iyunv@vm01 ~]# yum -y groupinstall "X Window System"
[iyunv@vm01 ~]# yum -y groupinstall "Desktop"
[iyunv@vm01 ~]# yum -y groupinstall "General Purpose Desktop"
[iyunv@vm01 ~]# startx //或者使用"init 5"命令来启动图形界面;关闭图形界面则需要执行"init 3"命令
执行上面startx命令后(可以放在后台执行,或者ctrl+z;bg 1;disown -a),就是把服务器的桌面模式启动了。使用VNC连接后,就会发现已经是桌面模式了。
2)修改centos系统以桌面模式启动
[iyunv@vm01 ~]# cat /etc/inittab
......
#id:3:initdefault: //以文本模式启动系统
id:5:initdefault: //以桌面模式启动系统
3)VNC远程桌面连接环境安装
[iyunv@vm01 ~]# ps -eaf|grep vnc
[iyunv@vm01 ~]# rpm -qa | grep vnc
安装VNC软件
[iyunv@vm01 ~]# yum install -y tigervnc tigervnc-server
[iyunv@vm01 ~]# yum install -y libvncserver*
[iyunv@vm01 ~]# rpm -qa | grep vnc
libvncserver-0.9.7-7.el6_6.1.x86_64
tigervnc-server-1.1.0-24.el6.x86_64
libvncserver-devel-0.9.7-7.el6_6.1.x86_64
tigervnc-1.1.0-24.el6.x86_64
------------------------------------------------------------------------------------
注意:
如果上面yum安装不行,可以直接下载rpm包进行安装:vnc-server-4.1.2-14.el5_6.6.x86_64.rpm
下载地址:https://pan.baidu.com/s/1nv1esBn
提取密码:syba
[iyunv@vm01 ~]# rpm -ivh vnc-server-4.1.2-14.el5_6.6.x86_64.rpm
------------------------------------------------------------------------------------
安装gnome软件,即安装生成图形界面锁需要的组件:
[iyunv@vm01 ~]# yum install -y gnome*
[iyunv@vm01 ~]# yum install libXfont -y
[iyunv@vm01 ~]# yum install xorg-x11-xfs
[iyunv@vm01 ~]# yum install xorg-x11-xfs-utils
[iyunv@vm01 ~]# yum install xorg-x11-xinit
[iyunv@vm01 ~]# yum install xorg-x11-xdm
[iyunv@vm01 ~]# yum install xorg-x11-fonts*
配置vncservers
配置vncservers,这里显示vnc远程连接到服务器的桌面窗口初始化大小,默认是800x600你也可以设置成你习惯的模式比如1280x960:
[iyunv@vm01 ~]# vim /etc/sysconfig/vncservers
......
VNCSERVERS="1:root"
VNCSERVERARGS[1]="-geometry 800x600"
设置vncserver密码
启动vnc之前必须设置密码:
[iyunv@vm01 ~]# vncpasswd
Password:
Verify:
启动停止vncserver
[iyunv@vm01 ~]# service vncserver start/stop/restart
默认监听端口是:5901
[iyunv@vm01 ~]# ps -ef|grep vnc
root 3950 1 0 01:15 pts/0 00:00:00 /usr/bin/Xvnc :1 -desktop vm01:1 (root) -auth /root/.Xauthority -geometry 800x600 -rfbwait 30000 -rfbauth /root/.vnc/passwd -rfbport 5901 -fp catalogue:/etc/X11/fontpath.d -pn
root 3958 3957 0 01:15 pts/0 00:00:00 vncconfig -iconic
root 4145 3323 0 01:30 pts/0 00:00:00 grep vnc
[iyunv@vm01 ~]# lsof -i:5901
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
Xvnc 3950 root 5u IPv4 55672 0t0 TCP *:5901 (LISTEN)
[iyunv@vm01 ~]#
配置xstartup启动命令
将/root/.vnc/xstartup文件内容复制成下面的内容
[iyunv@vm01 ~]# cp /root/.vnc/xstartup /root/.vnc/xstartup.bak
[iyunv@vm01 ~]# vim /root/.vnc/xstartup
#!/bin/sh
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#twm &
gnome-session &
然后重启vnc服务
[iyunv@vm01 ~]# service vncserver restart
--------------------------------------------------------------------
针对上面启动文件内容:
1)如果使用的是gnome图像界面,则需要注释掉以下两行,
xterm -geometry80x24+10+10 -ls -title “$VNCDESKTOP Desktop” &
twm &
并添加以下这行:
gnome-session &
2)如果黑屏了,后台日志报如下错误:
Sat May 7 15:05:35 2016
vncext: VNC extension running!
vncext: Listening for VNC connections on all interface(s), port 5901
vncext: created VNC server for screen 0
/root/.vnc/xstartup: line 4: /etc/X11/xinit/xinitrc: No such file or directory
/root/.vnc/xstartup: line 4: exec: /etc/X11/xinit/xinitrc: cannot execute: No such file or directory
然后去服务器检索 xinitrc检索不到的话,如下所示:
[iyunv@vm01 ~]# ll /etc/X11/xinit/xinitrc
ls: cannot access /etc/X11/xinit/xinitrc: No such file or directory
[iyunv@vm01 ~]# find / -name xinitrc
[iyunv@vm01 ~]#
采用的方案就是,注释掉 /root/.vnc/xstartup 里面的exec /etc/X11/xinit/xinitrc,让vncserver去选择默认的,让vnc加载默认图形界面程序 就ok了
--------------------------------------------------------------------
改变xstartup的权限
这是很多人容易忽视的问题,也是造成连接成功后黑屏的原因之一。
在CentOS中,xstartup的文件路径为:/root/.vnc/ (可以通过locatexstartup来查看xstartup的文件路径)
所以需要执行:chmod 777/root/.vnc/xstartup来赋予权限。之后再重启下vncserver。
最后在本地windows安装vnc viewer,远程访问
在windows下安装vnc客户端,
下载地址:https://pan.baidu.com/s/1hrSIr4K
提取密码:dqdt
VNC远程连接信息(下面ip是VNC服务端的地址):
VNC Server: 172.16.220.139:5901
Encrytion:Let VNC Server choose
然后输入vncpasswd的密码即可完成VNC远程连接!
运维网声明
1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网 享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com