linux系統: CentOS6.7 Hadoop版本: 2.6.5 zookeeper版本: 3.4.8
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
必定不能在HPL/SQL
上使用Hive
語法的語句,要使用MySQL
或Oracle
等其餘HPL/SQL
支持的數據庫(具體可去官網查看),否則會報找不到dual
表或者dual
表中無該字段的錯誤,切記node
在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
mysql
HPL/SQL與Hive是經過thrift
方式鏈接, 編輯hive-site.xml
, 添加如下配置項linux
<property> <name>hive.server2.thrift.bind.host</name> <value>m1</value> </property> <property> <name>hive.server2.thrift.port</name> <value>10000</value> </property>
配置HPL/SQL與Hive的鏈接, 建立hplsql-site.xml
文件(若已有則無需建立), 並將如下配置項拷貝到文件中sql
<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.onerror</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>
啓動Hive服務,依照在hplsql-site.xml
文件中的配置去建立(默認是在default
庫中建立了dual
表)數據庫
use default; create table dual(DUMMY VARCHAR(1));
sh $HIVE_HOME/bin/hive --service metastore sh $HIVE_HOME/bin/hive --service hiveserver2