在Cloudera Hue中,添加Oracle数据查询

整个流程分几部分

安装Oracle

  1. 下载Oracle
  2. 安装Oracle
  3. 设置自启动服务
  4. 启动服务

Hue中连接Oracle

  1. 在Hue中添加服务
  2. 重启服务

下载Oracle
http://www.oracle.com/technetwork/database/database-technologies/express-edition/downloads/index.html
登陆oracle下载oracle-xe-11.2.0-1.0.x86_64.rpm.zip

#解压安装包
unzip oracle-xe-11.2.0-1.0.x86_64.rpm.zip

#安装
cd Disk1 && rpm -ivh oracle-xe-11.2.0-1.0.x86_64.rpm

#配置数据库,根据需要设置端口、用户名和密码
/etc/init.d/oracle-xe configure

#启动服务
service oracle-xe start
#/etc/init.d/oracle-xe start

#停止服务,手工停止命令
service oracle-xe stop
#/etc/init.d/oracle-xe stop

#设置自启动
sudo chkconfig oracle-xe on

#添加环境变量
source /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh
echo "source /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh" >> ~/.bash_profile

#连接数据库,默认用户名为system
sqlplus

数据库查询测试

[cloudera@quickstart ~]$ sqlplus 

SQL*Plus: Release 11.2.0.2.0 Production on Fri Oct 17 20:49:01 2014

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Enter user-name: system
Enter password: 

Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production

SQL> show user;
USER is "SYSTEM"
SQL> select * from all_users;

USERNAME			  USER_ID CREATED
------------------------------ ---------- ------------------
XS$NULL 		       2147483638 28-AUG-11
APEX_040000			       47 28-AUG-11
APEX_PUBLIC_USER		       45 28-AUG-11
FLOWS_FILES			       44 28-AUG-11
HR				       43 28-AUG-11
MDSYS				       42 28-AUG-11
ANONYMOUS			       35 28-AUG-11
XDB				       34 28-AUG-11
CTXSYS				       32 28-AUG-11
OUTLN					9 28-AUG-11
SYSTEM					5 28-AUG-11

USERNAME			  USER_ID CREATED
------------------------------ ---------- ------------------
SYS					0 28-AUG-11

12 rows selected.

SQL> 

详细流程参见:http://mutap.wordpress.com/2012/04/22/install-oracle-11g-xe-release-2-in-oracle-linux-6/

在Hue中添加Oracle的rdbms连接,配置文件如下
添加以下配置文件

  [[databases]]
    [[mysql]]
    nice_name="shuhai's mac"
    name=
    engine=mysql
    host=10.0.2.2
    port=3306
    user=root
    password=password

    [[oracle]]
    nice_name="cloudera's oracle"
    name=
    engine=oracle
    host=127.0.0.1
    port=1521
    user=system
    password=password
sudo vim /etc/hue/conf.empty/hue.ini
sudo service hue restart

如果出现系统错误,如`Error loading cx_Oracle module: No module named cx_Oracle`,需要使用`pip install cx_Oracle`

发表评论

电子邮件地址不会被公开。