1. 程式人生 > >新一代Hive客戶端工具:Beeline

新一代Hive客戶端工具:Beeline

Hive客戶端工具後續將使用Beeline 替代HiveCLI ,並且後續版本也會廢棄掉HiveCLI 客戶端工具。

BeelineHive新的命令列客戶端工具。

Beeline是從 Hive 0.11版本引入的。

HiveServer2 支援一個新的命令列Shell,稱為Beeline,它是基於SQLLine CLIJDBC客戶端。

Beeline支援嵌入模式(embedded mode)和遠端模式(remote mode)。在嵌入式模式下,執行嵌入式的Hive(類似Hive CLI),而遠端模式可以通過Thrift連線到獨立的HiveServer2程序上。從Hive 0.14版本開始,Beeline

使用HiveServer2工作時,它也會從HiveServer2輸出日誌資訊到STDERR

[[email protected] bin]# hive --service beeline

Beeline version 0.13.1-cdh5.3.4 by Apache Hive

beeline> !connect jdbc:hive2://SZB-L0007970:10000/annuity_safe

scan complete in 3ms

Connecting to jdbc:hive2://SZB-L0007970:10000/annuity_safe

Enter username for jdbc:hive2://SZB-L0007970:10000/annuity_safe: hive

Enter password for jdbc:hive2://SZB-L0007970:10000/annuity_safe: ****

Connected to: Apache Hive (version 0.13.1-cdh5.3.4)

Driver: Hive JDBC (version 0.13.1-cdh5.3.4)

Transaction isolation: TRANSACTION_REPEATABLE_READ

0: jdbc:hive2://SZB-L0007970:10000/annuity_sa> show tables;

+---------------------------------+--+

|            tab_name             |

+---------------------------------+--+

| orc_table                       |

| parquet_t                       |

| parquet_test                    |

| simple_table                    |

| spark_create                    |

| src                             |

| test_t                          |

| ylx_hbase_hive                  |

| ylx_hivehbase_cid               |

| ylx_map                         |

| ylx_multi_mapping               |

| ylx_pops                        |

+---------------------------------+--+

16 rows selected (0.227 seconds)

我們也可以通過命令列去執行SQL命令或指令碼:

[[email protected] bin]# beeline -u jdbc:hive2://SZB-L0007970:10000/annuity_safe --color=true --silent=false -e"show tables"

scan complete in 3ms

Connecting tojdbc:hive2://SZB-L0007970:10000/annuity_safe

Connected to: Apache Hive (version0.13.1-cdh5.3.4)

Driver: Hive JDBC (version 0.13.1-cdh5.3.4)

Transaction isolation:TRANSACTION_REPEATABLE_READ

+---------------------------------+--+

|           tab_name             |

+---------------------------------+--+

| orc_table                       |

| parquet_t                       |

| parquet_test                    |

| simple_table                    |

| spark_create                    |

| src                             |

| test_t                          |

| ylx_hbase_hive                  |

| ylx_hivehbase_cid               |

| ylx_map                         |

| ylx_multi_mapping               |

| ylx_pops                        |

+---------------------------------+--+

16 rows selected (0.151 seconds)

Beeline version 0.13.1-cdh5.3.4 by ApacheHive

Closing: 0:jdbc:hive2://SZB-L0007970:10000/annuity_safe

也可以執行SQL指令碼:

[[email protected] ~]# beeline -u jdbc:hive2://SZB-L0007970:10000/annuity_safe  -f  beeline.sql

scan complete in 3ms

Connecting tojdbc:hive2://SZB-L0007970:10000/annuity_safe

Connected to: Apache Hive (version0.13.1-cdh5.3.4)

Driver: Hive JDBC (version 0.13.1-cdh5.3.4)

Transaction isolation:TRANSACTION_REPEATABLE_READ

0: jdbc:hive2://SZB-L0007970:10000/annuity_sa>use annuity_safe;

No rows affected (0.052 seconds)

0:jdbc:hive2://SZB-L0007970:10000/annuity_sa> show tables;

+---------------------------------+--+

|           tab_name             |

+---------------------------------+--+

| orc_table                       |

| parquet_t                       |

| parquet_test                    |

| simple_table                    |

| spark_create                    |

| src                             |

| test_t                          |

| ylx_hbase_hive                  |

| ylx_hivehbase_cid               |

| ylx_map                         |

| ylx_multi_mapping               |

| ylx_pops                        |

+---------------------------------+--+

16 rows selected (0.132 seconds)

0:jdbc:hive2://SZB-L0007970:10000/annuity_sa>

Closing: 0: jdbc:hive2://SZB-L0007970:10000/annuity_safe

[[email protected] ~]#

執行初始化SQL檔案:

[[email protected] ~]# beeline -u jdbc:hive2://SZB-L0007970:10000/annuity_safe -i beeline.sql

scan complete in 2ms

Connecting tojdbc:hive2://SZB-L0007970:10000/annuity_safe

Connected to: Apache Hive (version0.13.1-cdh5.3.4)

Driver: Hive JDBC (version 0.13.1-cdh5.3.4)

Transaction isolation:TRANSACTION_REPEATABLE_READ

Running init script beeline.sql

0:jdbc:hive2://SZB-L0007970:10000/annuity_sa> use annuity_safe;

No rows affected (0.052 seconds)

0:jdbc:hive2://SZB-L0007970:10000/annuity_sa> show tables;

+---------------------------------+--+

|           tab_name             |

+---------------------------------+--+

| orc_table                       |

| parquet_t                       |

| parquet_test                    |

| simple_table                    |

| spark_create                    |

| src                             |

| test_t                          |

| ylx_hbase_hive                  |

| ylx_hivehbase_cid               |

| ylx_map                         |

| ylx_multi_mapping               |

| ylx_pops                        |

+---------------------------------+--+

16 rows selected (0.136 seconds)

0:jdbc:hive2://SZB-L0007970:10000/annuity_sa>

Beeline version 0.13.1-cdh5.3.4 by ApacheHive

0: jdbc:hive2://SZB-L0007970:10000/annuity_sa>select max(key) from test_t;

Error: Error while processing statement: FAILED: ExecutionError, return code 1 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask(state=08S01,code=1)

解釋:這個如果不跟使用者名稱和密碼登陸beeline的話,就會報這個錯誤。

下面我們通過Beeline登陸Hive伺服器時要指定使用者名稱和密碼。

[[email protected] ~]# beeline -ujdbc:hive2://SZB-L0007970:10000/annuity_safe -n hive -p hive -i beeline.sql

scan complete in 2ms

Connecting tojdbc:hive2://SZB-L0007970:10000/annuity_safe

Connected to: Apache Hive (version0.13.1-cdh5.3.4)

Driver: Hive JDBC (version 0.13.1-cdh5.3.4)

Transaction isolation:TRANSACTION_REPEATABLE_READ

Running init script beeline.sql

0:jdbc:hive2://SZB-L0007970:10000/annuity_sa> use annuity_safe;

No rows affected (0.043 seconds)

0:jdbc:hive2://SZB-L0007970:10000/annuity_sa> show tables;

+---------------------------------+--+

|           tab_name             |

+---------------------------------+--+

| orc_table                       |

| parquet_t                       |

| parquet_test                    |

| simple_table                    |

| spark_create                    |

| src                             |

| test_t                          |

| ylx_hbase_hive                  |

| ylx_hivehbase_cid               |

| ylx_map                         |

| ylx_multi_mapping               |

| ylx_pops                        |

+---------------------------------+--+

16 rows selected (0.145 seconds)

0:jdbc:hive2://SZB-L0007970:10000/annuity_sa> select * from test_t;

+-------------+---------------+--+

| test_t.key  | test_t.value  |

+-------------+---------------+--+

| 1           | pingan        |

| 2           | huazhong      |

+-------------+---------------+--+

2 rows selected (0.227 seconds)

0:jdbc:hive2://SZB-L0007970:10000/annuity_sa> select max(key) from test_t;

+------+--+

| _c0 |

+------+--+

| 2   |

+------+--+

1 row selected (30.606 seconds)

0:jdbc:hive2://SZB-L0007970:10000/annuity_sa>

這樣就可以在Beeline裡面對Hive執行相關操作了。

說明一下:

引數-f和-i的區別是:

-f執行SQL檔案後就直接退出Beeline客戶端

而-i執行SQL檔案後進行Beeline客戶端。

如果想檢視beeline的幫助資訊,執行如下命令:

[[email protected] bin]# beeline --help

Usage: javaorg.apache.hive.cli.beeline.BeeLine

   -u <database url>               the JDBC URL to connect to

   -n <username>                   the username to connect as

   -p<password>                   thepassword to connect as

   -d<driver class>               thedriver class to use

   -i <initfile>                  script file forinitialization

   -e<query>                      query that should be executed

   -f <execfile>                  script filethat should be executed

  --hiveconf property=value      Use value for given property

  --hivevar name=value           hive variable name and value

                                   This is Hive specificsettings in which variables

                                   can be setat session level and referenced in Hive

                                   commands orqueries.

  --color=[true/false]           control whether color is used for display

  --showHeader=[true/false]      show column names in query results

  --headerInterval=ROWS;         the interval between which heades are displayed

  --fastConnect=[true/false]     skip building table/column list for tab-completion

   --autoCommit=[true/false]       enable/disable automatic transactioncommit

   --verbose=[true/false]          show verbose error messages and debuginfo

  --showWarnings=[true/false]    display connection warnings

  --showNestedErrs=[true/false]  display nested errors

  --numberFormat=[pattern]       format numbers using DecimalFormat pattern

  --force=[true/false]           continue running script even after errors

  --maxWidth=MAXWIDTH            the maximum width of the terminal

  --maxColumnWidth=MAXCOLWIDTH   the maximum width to use when displaying columns

  --silent=[true/false]           bemore silent

  --autosave=[true/false]        automatically save preferences

  --outputformat=[table/vertical/csv2/tsv2/dsv/csv/tsv]  format mode for result display

                                   Note thatcsv, and tsv are deprecated - use csv2, tsv2 instead

 --truncateTable=[true/false]   truncate table column when it exceeds length

  --delimiterForDSV=DELIMITER    specify the delimiter for delimiter-separated values output format(default: |)

  --isolation=LEVEL              set the transaction isolation level

   Setthe transaction isolation level to TRANSACTION_READ_COMMITTED 
or TRANSACTION_SERIALIZABLE.

  --nullemptystring=[true/false] set to true to get historic behavior of printing null as empty string

  --help                         display this message

Beeline version 0.13.1-cdh5.3.4 by ApacheHive

常用的一些命令總結:

(1)    reset

還原Beeline客戶端對Hive引數的設定

(2)    dfs

0:jdbc:hive2://SZB-L0007970:10000/annuity_sa> dfs -ls /apps-data;

+-----------------------------------------------------------------------------------+--+

|        DFS Output                                     |

+-----------------------------------------------------------------------------------+--+

|Found 1 items                                           |

| drwxr-xr-x - hdfs supergroup 0 2015-10-2216:13 /apps-data/hduser0103  |

+-----------------------------------------------------------------------------------+--+

2 rows selected (0.008 seconds)

0:jdbc:hive2://SZB-L0007970:10000/annuity_sa>

相關推薦

一代Hive客戶工具Beeline

Hive客戶端工具後續將使用Beeline 替代HiveCLI ,並且後續版本也會廢棄掉HiveCLI 客戶端工具。Beeline是Hive新的命令列客戶端工具。Beeline是從 Hive 0.11版本引入的。HiveServer2 支援一個新的命令列Shell,稱為Bee

LDAP基礎9客戶工具使用Apache Directory Studio進行操作

前面的文章介紹了LDAP伺服器的搭建以及通過ldap相關的命令進行操作的方法,對於不習慣*nix或命令列操作的使用者,也無需糾結,有很多不錯的客戶端工具可以實現這個功能,這篇文章介紹一下Apache Directory Studio。 Apache Directory Studio

[ 搭建Redis本地服務器實踐系列三 ] 圖解Redis客戶工具連接Redis服務器

done not 必須 tin 復雜 start exe eas 方便 上一章 [ 搭建Redis本地服務器實踐系列二 ] :圖解CentOS7配置Redis 介紹了Redis的初始化腳本文件及啟動配置文件,並圖解如何以服務的形式來啟動、終止Redis服務,可以說我們的R

Hive的命令列客戶啟動

[Spark][Hive]Hive的命令列客戶端啟動: [[email protected] Desktop]$ chkconfig | grep hive hive-metastore 0:off 1:off 2:off 3:on 4:on 5:on 6:off hive-ser

Hive mac 客戶工具DbVisualizer配置

1、下載連線Hive的GUI SQL工具 用命令列在hive上查看錶資料,當表資料量過大,每行資料過長時,資料檢視會變得不是很清晰直觀,但是DBVisualizer能夠輕鬆解決該問題,見下圖。  2、配置工具 先決條件 1.開啟D

Java客戶工具選擇HTML?Swing?XML?

整理下面的文章是因為個人覺得寫的很好,關於java的客戶端了解也並不是太多。看了下面的文章覺得很有必要貼出來,方便自己以後瞭解java客戶端程式設計。 Java軟體設計師和管理人員經常會面臨這樣的難題:在開發應用軟體的客戶端時,應該在Swing、HTML、XML三種技術中選

oracle入門很簡單五、oracle自帶的客戶工具sqlplus/sqlplusw

一般只要安裝了Oracle的伺服器端或者客戶端,sqlplus都被預設安裝。而sqlplusw只是在sqlplus上添加了一個窗體,在其上執行SQL語句與sqlplus完全相同。sqlplus的主要應用場景為檢視/設定資料庫引數、執行SQL指令碼等。 1.利用sqlpl

OpenSSH客戶漏洞CVE-2016-0777和CVE-2016-0778

ddr cdir -h 我們 class all 信息泄漏 提示信息 禁用 CVE-2016-0777可通過構造ssh惡意服務器,有可能泄漏客戶端的內存私鑰 詳細參考: 1. https://www.qualys.com/2016/01/14/cve-2016-0777-c

mysql 客戶工具參數詳解

mysql 客戶端工具參數詳解客戶端工具:mysql,mysqladmin,mysqldump,mysqlcheck非客戶端類的管理工具:myisamchk,myisampackmysql命令提示符mysql> 等待輸入命令‘> 前面提供的‘未提供結束’”>`>—> 續航符/*

PostgreSQL 圖形化客戶工具的使用技巧你都get了嗎?

scrip pos sta har 但是 聚類 發現 功能 containe PostgreSQL 數據庫作為目前功能較強大的開源數據庫,得到了廣泛應用。其中,TSA就用到了這款數據庫來存儲處理後的一些業務數據。雖然PostgreSQL自身提供了命令行交互式客戶端工具psq

+++++++icfg,ip,nmcli網絡屬性配置及網絡客戶工具使用

linuxLinux主機聯網:ifcofnig,route,netstat,ip,ss別名、主機名、接口命名網絡客戶端工具命令: ftp,lftp,wget,lftpgetnmap,ncat,tcpdump工具nmcli,nmtui <沒有CentOS 7 不能使用。。以後在補>Linux主機聯網

MySQL初始化以及客戶工具的使用

sock 詳細信息 linux form 關系型 orm ctr create 主機名                       MySQL初始化以及客戶端工具的使用                                             作者:尹正傑 版

dovecot並發數造成foxmail、outlook等客戶工具接收郵件有時候報錯

ash als stat class false limit var proc net 問題:dovecot並發數造成foxmail、outlook等客戶端工具接收郵件有時候報錯,頻繁點收取郵件報錯。/var/log/maillog日誌有大量的報錯:Jan 24 14:01

dovecot vsz_limit參造成foxmail、outlook等客戶工具接收郵件有時候報錯

客戶 大量 fat foxmail 解決 ase toolbar ron memory 問題:dovecot並發數造成foxmail、outlook等客戶端工具接收郵件有時候報錯,關閉客戶端工具後又可以了。/var/log/maillog日誌有大量的報錯:Jan 25 08

網絡客戶工具

建立 錯誤 ftp服務器 客戶 head ike 問題 ssh配置文件 flat ftp ,lftp,sftp ftp — Internet file transfer program ftp [-pinegvd] [host] -d: 詳細

網絡客戶工具—ftp、lftp、wget

ftp lftp wget ftp命令系統默認沒有安裝ftp命令的軟件包[root@CentOS6 ~]# yum -y install ftp ... Running Transaction Installing : ftp-0.17-54.el6.x86_64

outlook等客戶工具外發郵件提示550 5.7.1 Unable to relay for

Unable to relay for問題現象:outlook、foxmail等客戶端工具外發郵件提示550 5.7.1 Unable to relay for(發內網郵件不會)、網頁方式發送外網和內網郵件都可以。解決辦法:可能性1:在exchange郵件服務器中,發現默認的SMTP虛擬服務沒有啟用;於是啟動

MySQL客戶工具以及常用SQL語句

SQL語句Mysql客戶端工具: 在用yum安裝的maiadb-server的時候,在/etc/my.cnf.d下有一個名為client.cnf的文件,編輯此文件,在此文件的[client]下添加用戶名和密碼就可以不用輸入口令登錄 vim /etc/my.cnf.d/client.cn

實戰作業2,配置yum客戶工具

yum 程序包 管理 rpm 更多內容請點擊: Linux學習從入門到打死也不放棄,完全筆記整理(持續更新,求收藏,求點贊~~~~) http://blog.51cto.com/13683480/2095439 rpm是一款很好用

010-PLSQL Developer 客戶工具的安裝

設置環境變量 eve tns oracle安裝 reg 開始 32位 頁面 說明 安裝之前先把客戶端工具instantclient_12_1拷貝到一個沒有中文和空格的目錄中去, 比如我直接放到了D:\tools下面。註意這裏需要的是32bit的。 下面開始安裝PLS