软件环境:
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
```