軟件環境:
linux系統: CentOS6.7
Hadoop版本: 2.6.5
zookeeper版本: 3.4.8
##主機配置: ######一共m1, m2, m3這五部機, 每部主機的用戶名都為centos ``` 192.168.179.201: m1 192.168.179.202: m2 192.168.179.203: m3
m1: Zookeeper, Namenode, DataNode, ResourceManager, NodeManager, Master, Worker
m2: Zookeeper, Namenode, DataNode, ResourceManager, NodeManager, Worker
m3: Zookeeper, DataNode, NodeManager, Worker
####資料:
搭建教程:
http://lxw1234.com/archives/2015/09/487.htm
下載HPL/SQL地址:
http://www.hplsql.org/download
HPL/SQL官網:
http://www.hplsql.org/doc
---
<br>
####注意事項:
一定不能在`HPL/SQL`上使用`Hive`語法的語句,要使用`MySQL`或`Oracle`等其他`HPL/SQL`支持的數據庫(具體可去官網查看),不然會報找不到`dual`表或者`dual`表中無該字段的錯誤,切記
---
####版本選擇:
在`HPL/SQL0.3.17`版本(必須是0.3.17或者0.3.17之后的版本)解決了強制讀`From dual`表的問題, 而本次安裝的是`Hive2.1.1`版本自帶的是`HPLSQL0.3.31`版本, 已解決強制讀`From dual`表的問題.
若要解決強制讀`From dual`表的問題,應下載一個0.3.17或0.3.17之后版本的`HPL/SQL`, 然后將解壓后得到的hplsql-0.3.17.jar包放入`$HIVE_HOME/lib`包下, 並重命名為`hive-hplsql-*.jar`格式的包,如:`hive-hplsql-0.3.17.jar`
---
<br>
<br>
####1.編輯hive-site.xml文件
HPL/SQL與Hive是通過`thrift`方式連接, 編輯`hive-site.xml`, 添加以下配置項
hive.server2.thrift.bind.host
m1
hive.server2.thrift.port
10000
```
####2.編輯hplsql-site.xml文件 配置HPL/SQL與Hive的連接, 創建`hplsql-site.xml`文件(若已有則無需創建), 並將以下配置項拷貝到文件中 ```
hplsql.conn.default
hive2conn
The default connection profile
hplsql.conn.hiveconn
org.apache.hadoop.hive.jdbc.HiveDriver;jdbc:hive://
Hive embedded JDBC (not requiring HiveServer)
hplsql.conn.init.hiveconn
set mapred.job.queue.name=default; set hive.execution.engine=mr; use default;
Statements for execute after connection to the database
hplsql.conn.convert.hiveconn
true
Convert SQL statements before execution
hplsql.conn.hive2conn
org.apache.hive.jdbc.HiveDriver;jdbc:hive2://m1:10000
HiveServer2 JDBC connection
hplsql.conn.init.hive2conn
set mapred.job.queue.name=default; set hive.execution.engine=mr; use default;
Statements for execute after connection to the database
hplsql.conn.convert.hive2conn
true
Convert SQL statements before execution
hplsql.conn.db2conn
com.ibm.db2.jcc.DB2Driver;jdbc:db2://localhost:50001/dbname;user;password
IBM DB2 connection
hplsql.conn.tdconn
com.teradata.jdbc.TeraDriver;jdbc:teradata://localhost/database=dbname,logmech=ldap;user;password
Teradata connection
hplsql.conn.mysqlconn
com.mysql.jdbc.Driver;jdbc:mysql://localhost/test;user;password
MySQL connection
hplsql.dual.table
default.dual
Single row, single column table for internal operations
hplsql.insert.values
native
How to execute INSERT VALUES statement: native (default) and select
hplsql.onerror
exception
Error handling behavior: exception (default), seterror and stop
hplsql.temp.tables
native
Temporary tables: native (default) and managed
hplsql.temp.tables.schema
Schema for managed temporary tables
hplsql.temp.tables.location
/home/centos/soft/hive/tmp/plhql
LOcation for managed temporary tables in HDFS
hive.server2.thrift.bind.host
m1
hive.server2.thrift.port
10000
```
####3.配置dual表 (此步驟可跳過) 啟動Hive服務,依照在`hplsql-site.xml`文件中的配置去創建(默認是在`default`庫中創建了`dual`表) ``` use default; create table dual(DUMMY VARCHAR(1)); ```
####4.在使用hplsql存儲過程前, 需先啟動HiveServer2和Metastore服務 ``` sh $HIVE_HOME/bin/hive --service metastore sh $HIVE_HOME/bin/hive --service hiveserver2 ```