python 連接 hive 的 HiveServer2 的配置坑


環境:

  • hadoop 2.7.6
  • hive 2.3.4

Hive 的 thirft 啟動:

  • hadoop 單機或者集群需要:
    • 啟動 webhdfs
    • 修改 hadoop 的代理用戶 
<property>
  <name>hadoop.proxyuser.hadoop.hosts</name>
  <value>*</value>
</property>
<property>
  <name>hadoop.proxyuser.hadoop.groups</name>
  <value>*</value>
</property>

注:

hadoop.proxyuser.hadoop.hosts 中的 hadoop 代表任意節點的代理用戶(hadoop, 可以更換) 都能訪問 hdfs 集群。groups 表示代理用戶的所屬組

  • hive 配置
    • 注意 hive.server2.authentication 的方式 NOSASL(如下),與開發使用 pyhive (auth) 或者 impyla (auth_mechanism) 一致,防止出現: Error in sasl_client_start (-4) SASL(-4): no mechanism available:no mechanism available: Unable to find a callback: 2'") 之類的
<property>
    <name>hive.server2.authentication</name>
    <value>NOSASL</value>
    <description>
      Expects one of [nosasl, none, ldap, kerberos, pam, custom].
      Client authentication types.
        NONE: no authentication check
        LDAP: LDAP/AD based authentication
        KERBEROS: Kerberos/GSSAPI authentication
        CUSTOM: Custom authentication provider
                (Use with property hive.server2.custom.authentication.class)
        PAM: Pluggable authentication module
        NOSASL:  Raw transport
    </description>
</property>
    • hive.server2.enable.doAs
<property>
  <name>hive.server2.enable.doAs</name>
  <value>true</value>
</property>

注意:默認情況下,HiveServer2以提交查詢的用戶執行查詢訪問(true),如果hive.server2.enable.doAs設置為false,查詢將以運行hiveserver2進程的用戶訪問。

      • 與HTTP傳送相關的參數如下:
hive.server2.transport.mode – 默認值為binary(TCP),可選值HTTP。 
hive.server2.thrift.http.port– HTTP的監聽端口,默認值為10001。 
hive.server2.thrift.http.path – 服務的端點名稱,默認為 cliservice。 
hive.server2.thrift.http.min.worker.threads– 服務池中的最小工作線程,默認為5。 
hive.server2.thrift.http.max.worker.threads– 服務池中的最大工作線程,默認為500。 
      • 為了防止非加密模式下的內存泄露,可以通過設置下面的參數為true禁用文件系統的緩存: 
fs.hdfs.impl.disable.cache – 禁用HDFS文件系統緩存,默認值為false。 
fs.file.impl.disable.cache – 禁用本地文件系統緩存,默認值為false。 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM