1、 作为一名 DBA,在创建 Oracle 数据库的过程中一般要使用 dbca 和 netca 图像化进行建库和创建监听(如果使用脚本建库另说) ,如果您身体好估计可以在瑟瑟发抖的机房中完成数据库的创建过程,由于本人对寒冷比较敏感,有不想通过这样的方式锻炼身体,所以更愿意在舒适的房间内一边品味着咖啡的浓香,顺便度过相对枯燥的数据库安装和配置的过程,So,图形化操作工具是必不可少的,在 Linux 操作系统最流行的图形化操作软件莫过于 VNC,俺本着总结、共享及提醒的目的完成了这个详细的小文儿,希望大家喜欢。1.确认 VNC 是否安装默认情况下,Red Hat Enterprise Linux 安
2、装程序会将 VNC 服务安装在系统上。确认是否已经安装 VNC 服务及查看安装的 VNC 版本roottestdb # rpm -q vnc-servervnc-server-4.1.2-9.el5roottestdb #若系统没有安装,可以到操作系统安装盘的 Server 目录下找到 VNC 服务的 RPM 安装包 vnc-server-4.1.2-9.el5.x86_64.rpm,安装命令如下rpm -ivh /mnt/Server/vnc-server-4.1.2-9.el5.x86_64.rpm2.启动 VNC 服务使用 vncserver 命令启动 VNC 服务,命令格式为“vncs
3、erver :桌面号”,其中“ 桌面号”用“数字”的方式表示,每个用户连个需要占用 1 个桌面启动编号为 1 的桌面示例如下roottestdb # vncserver :1You will require a password to access your desktops.Password:Verify:xauth: creating new authority file /root/.XauthorityNew testdb:1 (root) desktop is testdb:1Creating default startup script. /root/.vnc/xstartupSt
4、arting applications specified in /root/.vnc/xstartupLog file is /root/.vnc/testdb:1.log以上命令执行的过程中,因为是第一次执行,需要输入密码,这个密码被加密保存在用户主目录下的.vnc 子目录(/root/.vnc/passwd )中;同时在用户主目录下的.vnc 子目录中为用户自动建立 xstartup 配置文件(/root/.vnc/xstartup) ,在每次启动 VND 服务时,都会读取该文件中的配置信息。BTW :/root/.vnc/ 目录下还有一个“testdb:1.pid”文件,这个文件记录着
5、启动 VNC 后对应后天操作系统的进程号,用于停止 VNC 服务时准确定位进程号。3.VNC 服务使用的端口号与桌面号的关系VNC 服务使用的端口号与桌面号相关,VNC 使用 TCP 端口从 5900 开始,对应关系如下桌面号为“1” - 端口号为 5901桌面号为“2” - 端口号为 5902桌面号为“3” - 端口号为 5903基于 Java 的 VNC 客户程序 Web 服务 TCP 端口从 5800 开始,也是与桌面号相关,对应关系如下桌面号为“1” - 端口号为 5801桌面号为“2” - 端口号为 5802桌面号为“3” - 端口号为 5803基于上面的介绍,如果 Linux 开启
6、了防火墙功能,就需要手工开启相应的端口,以开启桌面号为 “1”相应的端口为例,命令如下roottestdb # iptables -I INPUT -p tcp -dport 5901 -j ACCEPTroottestdb # iptables -I INPUT -p tcp -dport 5801 -j ACCEPT4.测试 VNC 服务第一种方法是使用 VNC Viewer 软件登陆测试,操作流程如下启动 VNC Viewer 软件 Server 输入“144.194.192.183:1” 点击“OK” Password 输入登陆密码 点击“OK”登陆到 X-Window 图形桌面环境
7、测试成功第二种方法是使用 Web 浏览器(如 Firefox,IE,Safari)登陆测试,操作流程如下地址栏输入 http:/144.194.192.183:5801/ 出现 VNC viewer for Java(此工具是使用 Java 编写的 VNC客户端程序)界面,同时跳出 VNC viewer 对话框,在 Server 处输入“144.194.192.183:1”点击“OK” Password 输入登陆密码 点击“OK”登陆到 X-Window 图形桌面环境 测试成功(注:VNC viewer for Java 需要 JRE 支持,如果页面无法显示,表示没有安装 JRE,可以到htt
8、p:/ 这里下载最新的 JRE 进行安装)5.配置 VNC 图形桌面环境为 KDE 或 GNOME 桌面环境如果您是按照我的上面方法进行的配置的,登陆到桌面后效果是非常简单的,只有一个 Shell 可供使用,这是为什么呢?怎么才能看到可爱并且美丽的 KDE 或 GNOME 桌面环境呢?回答如下之所以那么的难看,是因为 VNC 服务默认使用的是 twm 图形桌面环境的,可以在 VNC 的配置文件xstartup 中对其进行修改,先看一下这个配置文件roottestdb # cat /root/.vnc/xstartup#!/bin/sh# Uncomment the following two
9、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/.Xresourcesxsetroot -solid greyvncconfig -iconic &xterm -geometry 80x24+10+10 -ls -title “$VNCDESKTOP Desktop“ &twm &将这个 xstartup 文件的最后一行修改为“s
10、tartkde &”,再重新启动 vncserver 服务后就可以登陆到 KDE桌面环境将这个 xstartup 文件的最后一行修改为“gnome-session &”,再重新启动 vncserver 服务后就可以登陆到GNOME 桌面环境重新启动 vncserver 服务的方法:roottestdb # vncserver -kill :1roottestdb # vncserver :16.配置多个桌面可以使用如下的方法启动多个桌面的 VNCvncserver :1vncserver :2vncserver :3但是这种手工启动的方法在服务器重新启动之后将失效,因此,下面介绍如何让系统自动
11、管理多个桌面的 VNC,方法是将需要自动管理的信息添加到/etc/sysconfig/vncservers 配置文件中,先以桌面 1 为 root用户桌面 2 为 oracle 用户为例进行配置如下:格式为:VNCSERVERS=“ 桌面号:使用的用户名 桌面号:使用的用户名“roottestdb # vi /etc/sysconfig/vncserversVNCSERVERS=“1:root 2:oracle“VNCSERVERARGS1=“-geometry 1024x768“VNCSERVERARGS2=“-geometry 1024x768“7.修改 VNC 访问的密码使用命令 vnc
12、passwd 对不同用户的 VNC 的密码进行修改,一定要注意,如果配置了不同用户的 VNC需要分别到各自用户中进行修改,例如在我的这个实验中,root 用户和 oracle 用户需要分别修改,修改过程如下:roottestdb # vncpasswdPassword:Verify:roottestdb #8.启动和停止 VNC 服务1)启动 VNC 服务命令roottestdb # /etc/init.d/vncserver startStarting VNC server: 1:rootNew testdb:1 (root) desktop is testdb:1Starting appl
13、ications specified in /root/.vnc/xstartupLog file is /root/.vnc/testdb:1.log2:oracleNew testdb:2 (oracle) desktop is testdb:2Starting applications specified in /home/oracle/.vnc/xstartupLog file is /home/oracle/.vnc/testdb:2.log OK2)停止 VNC 服务命令roottestdb # /etc/init.d/vncserver stopShutting down VNC
14、 server: 1:root 2:oracle OK 3)重新启动 VNC 服务命令roottestdb # /etc/init.d/vncserver restartShutting down VNC server: 1:root 2:oracle OK Starting VNC server: 1:rootNew testdb:1 (root) desktop is testdb:1Starting applications specified in /root/.vnc/xstartupLog file is /root/.vnc/testdb:1.log2:oracleNew tes
15、tdb:2 (oracle) desktop is testdb:2Starting applications specified in /home/oracle/.vnc/xstartupLog file is /home/oracle/.vnc/testdb:2.log OK 4)设置 VNC 服务随系统启动自动加载第一种方法:使用“ntsysv”命令启动图形化服务配置程序,在 vncserver 服务前加上星号,点击确定,配置完成。第二种方法:使用“chkconfig”在命令行模式下进行操作,命令使用如下(预知 chkconfig 详细使用方法请自助式 man 一下)roottestdb # chkconfig vncserver onroottestdb # chkconfig -list vncservervncserver 0:off 1:off 2:on 3:on 4:on 5:on 6:off