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 </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> |
注:IPAddress為hive服務對應的IP地址。