软件环境:
linux系统: CentOS6.7Hadoop版本: 2.6.5zookeeper版本: 3.4.8
</br>
主机配置:
一共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, Workerm2: Zookeeper, Namenode, DataNode, ResourceManager, NodeManager, Workerm3: Zookeeper, DataNode, NodeManager, Worker
资料:
搭建教程: http://lxw1234.com/archives/2015/09/487.htm 下载HPL/SQL地址: http://www.hplsql.org/downloadHPL/SQL官网: http://www.hplsql.org/doc
注意事项:
一定不能在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
, 添加以下配置项
<property> <name>hive.server2.thrift.bind.host</name> <value>m1</value></property><property> <name>hive.server2.thrift.port</name> <value>10000</value></property>
</br>
2.编辑hplsql-site.xml文件
配置HPL/SQL与Hive的连接, 创建hplsql-site.xml
文件(若已有则无需创建), 并将以下配置项拷贝到文件中
<configuration><property> <name>hplsql.conn.default</name> <value>hive2conn</value> <description>The default connection profile</description></property><property> <name>hplsql.conn.hiveconn</name> <value>org.apache.hadoop.hive.jdbc.HiveDriver;jdbc:hive://</value> <description>Hive embedded JDBC (not requiring HiveServer)</description></property><!-- 配置项hive.execution.engine默认设置为mr,若使用spark作为引擎时,则设置为spark --><property> <name>hplsql.conn.init.hiveconn</name> <value> set mapred.job.queue.name=default; set hive.execution.engine=mr; use default; </value> <description>Statements for execute after connection to the database</description></property><property> <name>hplsql.conn.convert.hiveconn</name> <value>true</value> <description>Convert SQL statements before execution</description></property><property> <name>hplsql.conn.hive2conn</name> <value>org.apache.hive.jdbc.HiveDriver;jdbc:hive2://m1:10000</value> <description>HiveServer2 JDBC connection</description></property><!-- 配置项hive.execution.engine默认设置为mr,若使用spark作为引擎时,则设置为spark --><property> <name>hplsql.conn.init.hive2conn</name> <value> set mapred.job.queue.name=default; set hive.execution.engine=mr; use default; </value> <description>Statements for execute after connection to the database</description></property><property> <name>hplsql.conn.convert.hive2conn</name> <value>true</value> <description>Convert SQL statements before execution</description></property><property> <name>hplsql.conn.db2conn</name> <value>com.ibm.db2.jcc.DB2Driver;jdbc:db2://localhost:50001/dbname;user;password</value> <description>IBM DB2 connection</description></property><property> <name>hplsql.conn.tdconn</name> <value>com.teradata.jdbc.TeraDriver;jdbc:teradata://localhost/database=dbname,logmech=ldap;user;password</value> <description>Teradata connection</description></property><property> <name>hplsql.conn.mysqlconn</name> <value>com.mysql.jdbc.Driver;jdbc:mysql://localhost/test;user;password</value> <description>MySQL connection</description></property><property> <name>hplsql.dual.table</name> <value>default.dual</value> <description>Single row, single column table for internal operations</description></property><property> <name>hplsql.insert.values</name> <value>native</value> <description>How to execute INSERT VALUES statement: native (default) and select</description></property><property> <name>hplsql.</name> <value>exception</value> <description>Error handling behavior: exception (default), seterror and stop</description></property><property> <name>hplsql.temp.tables</name> <value>native</value> <description>Temporary tables: native (default) and managed</description></property><property> <name>hplsql.temp.tables.schema</name> <value></value> <description>Schema for managed temporary tables</description></property><property> <name>hplsql.temp.tables.location</name> <value>/home/centos/soft/hive/tmp/plhql</value> <description>LOcation for managed temporary tables in HDFS</description></property><!-- 下面两项需要按实际情况修改 --><property><name>hive.server2.thrift.bind.host</name><value>m1</value></property><property><name>hive.server2.thrift.port</name><value>10000</value></property></configuration>
</br>
3.配置dual表 (此步骤可跳过)
启动Hive服务,依照在hplsql-site.xml
文件中的配置去创建(默认是在default
库中创建了dual
表)
use default;create table dual(DUMMY VARCHAR(1));
</br>
4.在使用hplsql存储过程前, 需先启动HiveServer2和Metastore服务
sh $HIVE_HOME/bin/hive --service metastore sh $HIVE_HOME/bin/hive --service hiveserver2
</br>
</br>
</br>
作者:咸鱼翻身记
链接:https://www.jianshu.com/p/4d2035377753