1. hiveServer解釋
? ? 官方解釋:
HiveServer2 (HS2) is a server interface that enables remote clients to execute queries against Hive and retrieve the results (a more detailed intro here).
The current implementation, based on Thrift RPC, is an improved version of HiveServer and supports multi-client concurrency and authentication.
HiveServer2(HS2)是一個服務(wù)端接口,使遠程客戶端可以執(zhí)行對Hive的查詢并返回結(jié)果。目前基于Thrift RPC的實現(xiàn)是HiveServer的改進版本,并支持多客戶端并發(fā)和身份驗證
2.hiveserver與hive的關(guān)系

從圖中看出 hiveserver是hive與client端的交換終端,client通過hiveserver構(gòu)建查詢語句,訪問hadoop,并把數(shù)據(jù)通過hiveserver返回到client端
3.hiveserver架構(gòu)
hiveserver的核心是基于Thrift,Thrift負責hive的查詢服務(wù),Thtift是構(gòu)建跨平臺的rpc框架,主要由四層組成:server,Transport,Protocol和處理器
3.1 server
?hiveserver 在TCP模式下使用TThreadPoolServer , 在HTTP下使用jetty server
?server主要為每個tpc連接分配一個工作線程
3.2 Transport
如果客戶端與服務(wù)器之間需要代碼(安全原因),則需要http模式,通過hive配置屬性?hive.server2.transport.mode指定Thrift服務(wù)的傳輸模式
3.3 Protocol
協(xié)議主要負責序列化和反序列化
3.4 處理器
處理請求的應(yīng)用程序框架,實現(xiàn)了編譯和執(zhí)行hive查詢的邏輯,負責準備各種執(zhí)行引擎的物理執(zhí)行計劃
4.hiveserver的訪問方式
? ?1?????hive 命令行模式,直接輸入/hive/bin/hive的執(zhí)行程序,或者輸入 hive --service cli
? ?2????hive web界面的 (端口號9999) 啟動方式 hive –service hwi & 用于通過瀏覽器來訪問hive,感覺沒多大用途
? 3????hive 遠程服務(wù) (端口號10000) 啟動方式
? ? ?hive --service hiveserver &? 或者 hive --service hiveserver 10000>/dev/null 2>/dev/null &
????beeline方式連接:beeline -u jdbc:hive2//localhost:10000/default -n root -p 123456? ? 或者java client方式連接
????備注:連接Hive JDBC URL:jdbc:hive://192.168.6.116:10000/default? ? (Hive默認端口:10000? 默認數(shù)據(jù)庫名:default)