1. 程式人生 > >hive的訪問:通過JDBC遠端連線hive資料倉庫

hive的訪問:通過JDBC遠端連線hive資料倉庫

hive的訪問:終端訪問  遠端訪問

終端訪問:安裝hive,利用shell指令碼訪問 不可併發訪問

遠端訪問:通過JDBC連線資料倉庫 支援併發訪問

  • 啟動hiveserver2服務:檢視該命令可知hiveserver2,等價於hive --service hiveserver2 &
[[email protected] /soft/hive/bin]$ cat hiveserver2
#!/usr/bin/env bash

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

bin=`dirname "$0"`
bin=`cd "$bin"; pwd`

. "$bin"/hive --service hiveserver2 "
[email protected]
"
[[email protected] /soft/hive/bin]$ hive --service hiveserver2 &
[1] 11638
[[email protected] /soft/hive/bin]$ jps
11652 VersionInfo
2325 DataNode
10710 NameNode
2665 ResourceManager
11387 RunJar
2525 JournalNode
2797 NodeManager
11677 Jps
[[email protected] /soft/hive/bin]$ netstat -anop |grep 10000
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 0.0.0.0:10000           0.0.0.0:*               LISTEN      11638/java           off (0.00/0/0)
[
[email protected]
/soft/hive/bin]$

啟動hiveserver2服務,檢視jps,發現出現了runjar程序  檢視埠10000是否啟動 

方法一:進入到beeline命令列 通過JDBC協議 連線到hive資料倉庫

beeline> !connect jdbc:hive2://localhost:10000/incubator
Connecting to jdbc:hive2://localhost:10000/incubator
Enter username for jdbc:hive2://localhost:10000/incubator:
Enter password for jdbc:hive2://localhost:10000/incubator:
Connected to: Apache Hive (version 2.3.3)
Driver: Hive JDBC (version 2.3.3)
Transaction isolation: TRANSACTION_REPEATABLE_READ
0: jdbc:hive2://localhost:10000/incubator> show tables;
+-----------+
| tab_name  |
+-----------+
| t         |
+-----------+
1 row selected (6.595 seconds)
0: jdbc:hive2://localhost:10000/incubator> select * from t;
+-------+---------+--------+
| t.id  | t.name  | t.age  |
+-------+---------+--------+
+-------+---------+--------+
No rows selected (6.435 seconds)
0: jdbc:hive2://localhost:10000/incubator>

方法二:通過api連線hive資料倉庫(前提是服務端已經啟動hiveserver2服務)

package com.hive;

import java.sql.*;

public class AcessApp {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        Class.forName("org.apache.hive.jdbc.HiveDriver");
        Connection con = DriverManager.getConnection("jdbc:hive2://192.168.109.150:10000/cr","xiaoqiu","0806");
        Statement st = con.createStatement();
        ResultSet rs = st.executeQuery("SELECT * from student");
        while (rs.next()){
            System.out.println(rs.getInt(1) + "," + rs.getString(2));
        }
        rs.close();
        st.close();
        con.close();
    }
}
3,yamy
4,sunny

相關推薦

hive訪問通過JDBC遠端連線hive資料倉庫

hive的訪問:終端訪問  遠端訪問 終端訪問:安裝hive,利用shell指令碼訪問 不可併發訪問 遠端訪問:通過JDBC連線資料倉庫 支援併發訪問 啟動hiveserver2服務:檢視該命令可知hiveserver2,等價於hive --service hive

java 通過jdbc驅動連線hive操作例項

               String insterSQL="LOAD DATA LOCAL INPATH '/work/hive/examples/files/kv1.txt' OVERWRITE INTO TABLE javabloger";                 String queryS

java 通過jdbc驅動連線hive操作

               String insterSQL="LOAD DATA LOCAL INPATH '/work/hive/examples/files/kv1.txt' OVERWRITE INTO TABLE javabloger";                 String query

java通過JDBC驅動連線操作hive例項

Hive提供了jdbc驅動,使得我們可以用java程式碼來連線Hive並進行一些類關係型資料庫的sql語句查詢等操作。首先,我們必須將Hive的服務,也就是HiveServe開啟。在Hive 0.11.0版本前,只有HiveServer服務可用,但是HiveServer本身存在很多問題(比如:安全性、併發性

遠端連線Hive配置

1、執行HiveServer2和Beeline    HiveServer2(在Hive 0.11中引入)有它自己的CLI,叫做Beeline.      HiveCLI現在不提倡使用,而是支援Beeline,因為HiveCLI缺乏對多使用者、安全以

Hive使用者介面(二)—使用Hive JDBC驅動連線Hive操作例項

問題導讀:         1、Hive提供了哪三種使用者訪問方式?         2、使用HiveServer時候,需要首先啟動哪個服務?         3、HiveServer的啟動命令是?         4、HiveServer是通過哪個服務來提供遠端JDBC訪

scala(一)通過jdbc連線mysql資料庫

1.主題描述 scala針對MySQL資料庫進行增刪改查的基本操作。 2.程式碼 package SparkSQLproject.Log import java.sql.{Connection, DriverManager} /** * scala通過jdb

JDBC方式連線Hive獲取進度資訊

最近做專案,有個小問題,JDBC連線hive操作後,由於hive的查詢一般都比較久,用beeline或者hive命令列去操作,都可以看到進度資訊,但普通的JDBC操作卻看不到進度資訊。需要獲取進度資訊,在網上沒有找到相關資料後。研究了一下beeline的原始碼。其實so e

python通過thrift方式連線hive

nohup hive --service metastore & [hadoop@master1 usr]$ hive Logging initialized using configuration in file:/data/usr/hive/conf/hive-log4j.propertie

Linuxmysql允許遠端連線

更新到2018-6-27 現在使用   阿里雲  伺服器,關於遠端連線MySQL的問題 首先要看看你的  阿里雲 伺服器 是否設定,開放了3306 埠。 然後再進行如下操作。 (其實很多  伺

通過Navicat遠端連線伺服器MySQL伺服器

1.檢視伺服器mysql許可權 select user,host from mysql.user; 2.看host許可權是否為%,如果不是可通過MySQL Workbench進行修改; 進入MySQL Workbench並且連線資料庫 單擊Users and Privile

Linux開發環境搭建與使用——通過xshell遠端連線ubuntu

由於xshell遠端連線ubuntu是通過ssh協議的,所以,需要給ubuntu安裝ssh伺服器。 1)ubuntu安裝ssh伺服器 sudo apt-get install openssh-server 2)出現問題時,重啟ssh服務即可 sudo se

通過linux遠端連線mysql,查詢結果中文為亂碼小結

首先本地辦公環境為windows使用的是navicat連線的mysql navicat連線mysql時查詢結果正常 檢視編碼方式: mysql> show variables like ‘%character%‘; +----------------------

Oracle 11g 安裝以及通過plsql遠端連線oracle

【摘要】       因為專案中涉及到oracle巡檢,為了驗證客戶提供的oracle巡檢語句,本人在虛擬機器(win10)搭建了一臺oracle(11g)資料庫,並同PLSQL Developer連線oracle,具體操作步驟如下: 一、oracle11g安裝 1、大

ERROR通過埠 1433 連線到主機 localhost 的 TCP/IP 連線失敗。錯誤:“Connection refused: connect。請驗證連線屬性,並檢查 SQL Server 的例項正在主機上執行,且在此埠接受 TCP/IP 連

ERROR:通過埠1433連線到主機localhost的TCP/IP連線失敗。錯誤:“Connection refused: connect。請驗證連線屬性,並檢查SQL Server的例項正在主機上執行,且在此埠接受TCP/IP連線,還要確保防火牆沒有阻止到此埠的TCP

CentOS7.4靜默安裝Oracle,並通過工具遠端連線

1.準備環境 1.工具Xshell用於操作CentOS7.4 2.CentOS7.4【虛擬機器】安裝oracle【oracle的版本是11g】 若用oracle 12c,環境依賴包可能會需要重新整理,另外安裝過程中dbca.rsp中的內容可能跟11g的有所出入,需要查閱

通過teamviewer 遠端連線 ubuntu 16.04.4 LTS

最近搞了個雲伺服器,之前都是通過XShell遠端命令列,用著也挺方便的,但是現在要在上面裝virtualbox安裝虛擬機器,結果發現還是有不少問題要解決: 1.在windows下遠端Ubuntu       之前用過VNC Viewer和VNC Server實現的方

Windows通過SSH遠端連線Linux

這裡的”遠端”操控的方法實際上也不是真正的遠端.,這此操作方法主要是在一個區域網內遠端操控電腦 (在一個路由器下)。可以把它做成在網際網路中的遠端操控, 不過技術難度上加了一個等級, 如果你想是想人在公司, 卻要操控家裡的 Linux, 可以參考免費的軟體 (TeamView

Windows10通過VNC遠端連線Ubuntu18.04

1.開啟終端輸入:sudo apt-get install xrdp vnc4server xbase-clients dconf-editor 2.接著在終端輸入: 進入到下面這個介面: 接著按照這個org > gnome > desktop > remote-acces

通過Xshell遠端連線虛擬機器VMVARE中的Ubuntu

本文將講解如何通過Xshell遠端連線虛擬機器中的Ubuntu,從而不必主系統和虛擬機器來回切換。 1. 下載並安裝Xshell 先下載並安裝合適版本的Xshell rj.baidu.com/soft/detail/15201.html?ald 2. 安裝SS