Hplsql报错:...HiveSQLExpection:Error while compiling statement:No privilege 'Select' found for inputs {.....}

实践hplsql时,遇到的问题总结一下,若有不对的地方,欢迎交流。


一、Hplsql简介

  hplsql的介绍详见:http://lxw1234.com/archives/2015/09/492.htm

 

二、hpsql的配置文件为hplsql-site.xml

  2.1 常见的选项列表:

hplsql.conn.default 指定默认的连接配置文件,默认值为hive2conn
hplsql.conn.hive2conn  指定HiveServer2JDBC连接
hplsql.conn.init.hive2conn

定义执行SQL语句连接后执行hive2conn 的一些默认设置,如:set system:user.name=mr;

set hive.execution.engine=mr(mr为MapReduce,也可以设置为spark);

hplsql.conn.convert.hive2conn 定义是否对即时SQL转换已启用hive2conn,默认为true
hplsql.conn.mysqlconn     指定MySQL数据库的连接配置文件

  2.2 对hplsql-site.xml配置

编辑hplsql-site.xml

修改或添加以下变量:

<property>

<name>hplsql.conn.default</name>

<value>hive2conn</value>

<description>The default connection profile</description>

</property>

<property>

<name>hplsql.conn.init.hive2conn</name>

<value>set system:user.name=mr;set hive.execution.engine=mr</value>

</property>

<property>

<name>hplsql.conn.hive2conn</name>

<value>org.apache.hive.jdbc.HiveDriver;jdbc:hive2://IPAddress:10000;username;password</value>

<description>HiveServer2 JDBC connection</description>

</property>

三、执行报错

  执行的命令为:

./hplsql -e "SELECT * FROM default.test LIMIT 10"

  3.1 报错信息:...HiveSQLExpection:Error while compiling statement:No privilege 'Select' found for inputs {.....}

  显示对表没有select权限。

  分析过程:

  1)使用命令vim hplsql脚本发现,该脚本主要是调用hive脚本;

  2)查看hive脚本,发现脚本使用环境变量HIVE_CONF_DIR;

  3)使用命令env|grep hive发现,环境变量HIVE_CONF_DIR未设置;

  4)在/etc/profile中加入export HIVE_CONF_DIR=/etc/hive/conf(根据hplsql-site.xml路径指定)

  3.2 报错信息:java.sql.SQLExpection:Could not open client transport with JDBC Uri:jdbc:hive2://localhost:10000:java.net.ConnetcExpection:拒绝连接

  一般为hive-site.xml文件配置问题

  分析过程:

  1)检查端口10000是否启动

netstat -anp|grep 10000

  2)检查hive-site.xml配置

<configuration>
<property>
<name>hive.server2.thrift.port</name>
<value>10000</value>
</property>
<property>
<name>hive.server2.thrift.bind.host</name>
<value>IPAddress</value>
</property>
</configuration>

注:IPAddress为hive服务对应的IP地址。

猜你喜欢

转载自www.cnblogs.com/love-yh/p/9949882.html