1. 程式人生 > >Hive(16):hiveserver2服務

Hive(16):hiveserver2服務

1、hiveserver2功能

    優勢:將hive變成一個服務對外開放,通過客戶端去連結。開啟hiveserver2,然後使用beeline客戶端訪問,有驗證的方法,從而限制使用者訪問許可權,保證資料庫安全。

2、啟動hiveserver2並且連線方法

(1)單獨啟動hiveserver2和beeline

    啟動服務  

bin/hiveserver2

    啟動客戶端

bin/beeline
!connect jdbc:hive2://bigdata.ibeifeng.com:10000

(2)一步到位

bin/beeline -u jdbc:hive2://bigdata.ibeifeng.com:10000 -n beifeng -p beifeng

3.配置方法

(1)在操作beeline的時候,hiveserver2會有回顯資訊,操作成功會有ok,失敗會有錯誤資訊
          所以在開啟bin/hiveserver2的時候,使用nohup讓程序在後臺啟動,並且把回顯的資料新增到文字中

nohup bin/hiveserver2  > myout.file 2>&1 &

(2)hiveserver2如果連結不上,超時,可以修改引數,把L去掉,新增到hive-site.xml

        <property>
            <name>hive.server2.long.polling.timeout</name>
            <value>5000L</value>
            <description>Time in milliseconds that HiveServer2 will wait, before responding to asynchronous calls that use long polling</description>
        </property>

(3)會發現hiveserver2幾乎沒有許可權驗證,是因為配置檔案中,預設沒有開啟

     <property>
        <name>hive.server2.authentication</name>
        <value>NONE</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>