下載須要的ojdbc6版本jar包,放在/home/hadoop/Downloads/目錄,後面須要將這個jar包添加到maven庫中以便編譯使用html
下載地址:http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090769.htmljava
添加ojdbc6.jar到maven庫中,相關jar會自動生成在~/.m2/mysql
mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0.4 -Dpackaging=jar -Dfile=/home/hadoop/Downloads/ojdbc6.jarlinux
[hadoop@breath Downloads]$ mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0.4 -Dpackaging=jar -Dfile=/home/hadoop/Downloads/ojdbc6.jar [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building Maven Stub Project (No POM) 1 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ standalone-pom --- [INFO] Installing /home/hadoop/Downloads/ojdbc6.jar to /home/hadoop/.m2/repository/com/oracle/ojdbc6/11.2.0.4/ojdbc6-11.2.0.4.jar [INFO] Installing /tmp/mvninstall4163536703052322468.pom to /home/hadoop/.m2/repository/com/oracle/ojdbc6/11.2.0.4/ojdbc6-11.2.0.4.pom [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.524 s [INFO] Finished at: 2017-05-07T13:56:39+08:00 [INFO] Final Memory: 9M/169M [INFO] ------------------------------------------------------------------------ |
編譯需使用jdk1.8最新。git
項目地址:https://github.com/marcelopaesrech/presto-oraclegithub
[hadoop@breath ~]$ cd /tmp [hadoop@breath tmp]$ git clone https://github.com/marcelopaesrech/presto-oracle.git 正克隆到 'presto-oracle'... remote: Counting objects: 58, done. remote: Total 58 (delta 0), reused 0 (delta 0), pack-reused 58 Unpacking objects: 100% (58/58), done. [hadoop@breath tmp]$ cd presto-oracle [hadoop@breath presto-oracle]$ java -version java version "1.8.0_121" Java(TM) SE Runtime Environment (build 1.8.0_121-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode) [hadoop@breath presto-oracle]$ mvn -v Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00) Maven home: /opt/beh/core/maven Java version: 1.8.0_121, vendor: Oracle Corporation Java home: /opt/beh/core/jdk1.8.0_121/jre Default locale: zh_CN, platform encoding: UTF-8 OS name: "linux", version: "3.10.0-327.22.2.el7.x86_64", arch: "amd64", family: "unix" |
修改pom.xml文件,修改成你須要部署的presto版本,sql
<version>0.147</version>oracle
<dep.presto.version>0.147</dep.presto.version>maven
這裏使用的是0.172,故修改成0.172oop
<version>0.172</version>
<dep.presto.version>0.172</dep.presto.version>
修改ojdbc6依賴。將以下部分修改
<dependency>
<groupId>ojdbc6</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.3</version>
</dependency>
爲
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.4</version>
</dependency>
進行編譯
mvn clean install
相關connector jar會生成在 target/presto-oracle-0.172.jar
[hadoop@breath presto-oracle]$ mvn clean install ... ... ... [INFO] Installing /tmp/presto-oracle/target/presto-oracle-0.172.jar to /home/hadoop/.m2/repository/ml/prestoconnectors/presto-oracle/0.172/presto-oracle-0.172.jar [INFO] Installing /tmp/presto-oracle/pom.xml to /home/hadoop/.m2/repository/ml/prestoconnectors/presto-oracle/0.172/presto-oracle-0.172.pom [INFO] Installing /tmp/presto-oracle/target/presto-oracle-0.172-sources.jar to /home/hadoop/.m2/repository/ml/prestoconnectors/presto-oracle/0.172/presto-oracle-0.172-sources.jar [INFO] Installing /tmp/presto-oracle/target/presto-oracle-0.172-javadoc.jar to /home/hadoop/.m2/repository/ml/prestoconnectors/presto-oracle/0.172/presto-oracle-0.172-javadoc.jar [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 01:38 min [INFO] Finished at: 2017-05-07T14:10:39+08:00 [INFO] Final Memory: 30M/224M [INFO] ------------------------------------------------------------------------ |
將jar拷貝到相關plugin/oracle目錄,先切換至presto安裝目錄
[hadoop@breath presto]$ cd $PRESTO_HOME [hadoop@breath presto]$ ll 總用量 216 drwxr-xr-x. 3 hadoop hadoop 4096 4月 11 10:23 bin drwxrwxr-x. 3 hadoop hadoop 39 4月 12 13:56 data drwxrwxr-x. 3 hadoop hadoop 4096 4月 12 13:58 etc drwxr-xr-x. 2 hadoop hadoop 8192 4月 10 08:47 lib -rw-r--r--. 1 hadoop hadoop 191539 4月 10 08:47 NOTICE drwxr-xr-x. 22 hadoop hadoop 4096 5月 7 14:14 plugin -rw-r--r--. 1 hadoop hadoop 119 4月 10 08:47 README.txt [hadoop@breath presto]$ rm plugin/oracle/mysql-connector* [hadoop@breath presto]$ rm plugin/oracle/presto-mysql* [hadoop@breath presto]$ mv /tmp/presto-oracle/target/presto-oracle*.jar plugin/oracle [hadoop@breath presto]$ cp /home/hadoop/Downloads/ojdbc6.jar plugin/oracle [hadoop@breath presto]$ ll plugin/oracle/presto-oracle-0.172.jar -rw-rw-r-- 1 hadoop hadoop 10400 5月 7 14:10 plugin/oracle/presto-oracle-0.172.jar |
建立配置文件$PRESTO_HOME/etc/catalog/oracle,並修改成相關的ip地址,端口,database,用戶,密碼。
connector.name=oracle # connection-url must me the URL to access Oracle via JDBC. It can be different depending on your environment. # Another example of the URL would be jdbc:oracle:thin:@//ip:port/database. For more information, please go to the JDBC driver docs connection-url=jdbc:oracle:thin://ip:port/database connection-user=myuser connection-password=