好玩的大數(shù)據(jù)之19:Hive實驗2(hive beeline)

一鞠评、簡介


Hive客戶端工具后續(xù)將使用Beeline?替代HiveCLI?,并且后續(xù)版本也會廢棄掉HiveCLI?客戶端工具,Beeline是?Hive 0.11版本引入的新命令行客戶端工具,它是基于SQLLine CLI的JDBC客戶端几迄。

Beeline支持嵌入模式(embedded mode)和遠(yuǎn)程模式(remote mode)。在嵌入式模式下,運(yùn)行嵌入式的Hive(類似Hive CLI)呵恢,而遠(yuǎn)程模式可以通過Thrift連接到獨立的HiveServer2進(jìn)程上种蘸。從Hive 0.14版本開始墓赴,Beeline使用HiveServer2工作時,它也會從HiveServer2輸出日志信息到STDERR航瞭。

二诫硕、啟動

? ? ? ? 1)啟動前確保hiveserver2服務(wù)已經(jīng)運(yùn)行? ? ? ??

????????????????啟動hive服務(wù)

????????????????????????hive --service metastore > $HIVE_HOME/working/logs/metastore.log 2>&1 &

????????? ??????啟動hiveserver2服務(wù)

????????????????????????hive --service hiveserver2 > $HIVE_HOME/working/logs/hiveserver2.log 2>&1 &

? ? ? ? ? ? ? ? 檢查

????????????????????????sudo netstat -tulnp | grep 10000

hiveserver2服務(wù)

? ? ? ? ? ? ? ? ? ? ? ? ps -ef|grep hiveserver2

? ? ? ? 2)beeline? --help

一定要善用help,不懂就問help?

Usage: java org.apache.hive.cli.beeline.BeeLine

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

? ?-n <username>? ? ? ? ? ? ? ? ? the username to connect as

? -p <password>? ? ? ? ? ? ? ? ? the password to connect as

? ?-e <query>? ? ? ? ? ? ? ? ? ? ? query that should be executed

? -f <exec file>? ? ? ? ? ? ? ? ? script file that should be executed

? -w (or) --password-file <password file>? the password file to read password from

? --hiveconf property=value? ? ? Use value for given property

? --help? ? ? ? ? ? ? ? ? ? ? ? ? display this message

? Example:

? ? 1. Connect using simple authentication to HiveServer2 on localhost:10000

? ? $ beeline -u jdbc:hive2://localhost:10000 username password

? ? 2. Connect using simple authentication to HiveServer2 on hs.local:10000 using -n for username and -p for password

? ? $ beeline -n username -p password -u jdbc:hive2://hs2.local:10000/default

? ? ? ? 3)啟動beeline

????????????????beeline -u jdbc:hive2://master:10000

? ? ? ? ? ? ? ? 或者

? ??????????????beeline

? ? ? ? ? ? ? ? ? ? ? ? !connect?jdbc:hive2://master:10000

? ? ? ? ? ? ? ? 在NONE認(rèn)證方式下刊侯,以上命令會直接進(jìn)入beeline shell

三章办、命令行help


在beeline下輸入help,會展示所有的beeline命令

help

!addlocaldriverjar? Add driver jar file in the beeline client side.

!addlocaldrivername Add driver name that needs to be supported in the beeline

? ? ? ? ? ? ? ? ? ? client side.

!all? ? ? ? ? ? ? ? Execute the specified SQL against all the current connections

!autocommit? ? ? ? Set autocommit mode on or off

!batch? ? ? ? ? ? ? Start or execute a batch of statements

!brief? ? ? ? ? ? ? Set verbose mode off

!call? ? ? ? ? ? ? Execute a callable statement

!close? ? ? ? ? ? ? Close the current connection to the database

!closeall? ? ? ? ? Close all current open connections

!columns? ? ? ? ? ? List all the columns for the specified table

!commit? ? ? ? ? ? Commit the current transaction (if autocommit is off)

!connect? ? ? ? ? ? Open a new connection to the database.

!dbinfo? ? ? ? ? ? Give metadata information about the database

!delimiter? ? ? ? ? Sets the query delimiter, defaults to ;

!describe? ? ? ? ? Describe a table

!dropall? ? ? ? ? ? Drop all tables in the current database

!exportedkeys? ? ? List all the exported keys for the specified table

!go? ? ? ? ? ? ? ? Select the current connection

!help? ? ? ? ? ? ? Print a summary of command usage

!history? ? ? ? ? ? Display the command history

!importedkeys? ? ? List all the imported keys for the specified table

!indexes? ? ? ? ? ? List all the indexes for the specified table

!isolation? ? ? ? ? Set the transaction isolation for this connection

!list? ? ? ? ? ? ? List the current connections

!manual? ? ? ? ? ? Display the BeeLine manual

!metadata? ? ? ? ? Obtain metadata information

!nativesql? ? ? ? ? Show the native SQL for the specified statement

!nullemptystring? ? Set to true to get historic behavior of printing null as

? ? ? ? ? ? ? ? ? ? empty string. Default is false.

!outputformat? ? ? Set the output format for displaying results

? ? ? ? ? ? ? ? ? ? (table,vertical,csv2,dsv,tsv2,xmlattrs,xmlelements, and

? ? ? ? ? ? ? ? ? ? deprecated formats(csv, tsv))

!primarykeys? ? ? ? List all the primary keys for the specified table

!procedures? ? ? ? List all the procedures

!properties? ? ? ? Connect to the database specified in the properties file(s)

!quit? ? ? ? ? ? ? Exits the program

!reconnect? ? ? ? ? Reconnect to the database

!record? ? ? ? ? ? Record all output to the specified file

!rehash? ? ? ? ? ? Fetch table and column names for command completion

!rollback? ? ? ? ? Roll back the current transaction (if autocommit is off)

!run? ? ? ? ? ? ? ? Run a script from the specified file

!save? ? ? ? ? ? ? Save the current variabes and aliases

!scan? ? ? ? ? ? ? Scan for installed JDBC drivers

!script? ? ? ? ? ? Start saving a script to a file

!set? ? ? ? ? ? ? ? Set a beeline variable

!sh? ? ? ? ? ? ? ? Execute a shell command

!sql? ? ? ? ? ? ? ? Execute a SQL command

!tables? ? ? ? ? ? List all the tables in the database

!typeinfo? ? ? ? ? Display the type map for the current connection

!verbose? ? ? ? ? ? Set verbose mode on

四滨彻、命令行實例


? ? 1.select version();

? ? ?2.list

? ? 2.list

????????????!list


????????? ? ? ??





六藕届、配置和排錯


1.用beeline/hive操作時,如何關(guān)閉打印多余的info亭饵?

????????a) 在使用beeline時加入以下設(shè)置即可–hiveconf hive.server2.logging.operation.level=NONE

????????b) 或者在hive-site.xml中加入如下配置也可以禁用在beeline中顯示額外信息

????<property>

? ? <name>hive.server2.logging.operation.enabled</name>

? ? <value>false</value>

? </property>

? <property>

? ? <name>hive.server2.logging.operation.log.location</name>

? ? <value>/mylab/soft/apache-hive-3.1.2-bin/working/operation_log</value>

? </property>

2.關(guān)于認(rèn)證

hive.site中搜? ??hive.server2.authentication休偶,有以下內(nèi)容

<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>

<property>

? ? <name>hive.server2.thrift.client.user</name>

? ? <value>anonymous</value>

? ? <description>Username to use against thrift client</description>

? </property>

? <property>

? ? <name>hive.server2.thrift.client.password</name>

? ? <value>anonymous</value>

? ? <description>Password to use against thrift client</description>

? </property>

? ?默認(rèn)認(rèn)證方式為NONE

? ?默認(rèn)用戶名/密碼配置為anonymous/anonymous

? ?需要時,設(shè)定用戶名和密碼

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末辜羊,一起剝皮案震驚了整個濱河市踏兜,隨后出現(xiàn)的幾起案子词顾,更是在濱河造成了極大的恐慌,老刑警劉巖碱妆,帶你破解...
    沈念sama閱讀 222,807評論 6 518
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件肉盹,死亡現(xiàn)場離奇詭異,居然都是意外死亡疹尾,警方通過查閱死者的電腦和手機(jī)上忍,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 95,284評論 3 399
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來纳本,“玉大人睡雇,你說我怎么就攤上這事∫迹” “怎么了它抱?”我有些...
    開封第一講書人閱讀 169,589評論 0 363
  • 文/不壞的土叔 我叫張陵,是天一觀的道長朴艰。 經(jīng)常有香客問我观蓄,道長,這世上最難降的妖魔是什么祠墅? 我笑而不...
    開封第一講書人閱讀 60,188評論 1 300
  • 正文 為了忘掉前任侮穿,我火速辦了婚禮,結(jié)果婚禮上毁嗦,老公的妹妹穿的比我還像新娘亲茅。我一直安慰自己,他們只是感情好狗准,可當(dāng)我...
    茶點故事閱讀 69,185評論 6 398
  • 文/花漫 我一把揭開白布克锣。 她就那樣靜靜地躺著,像睡著了一般腔长。 火紅的嫁衣襯著肌膚如雪袭祟。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 52,785評論 1 314
  • 那天捞附,我揣著相機(jī)與錄音巾乳,去河邊找鬼。 笑死鸟召,一個胖子當(dāng)著我的面吹牛胆绊,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播欧募,決...
    沈念sama閱讀 41,220評論 3 423
  • 文/蒼蘭香墨 我猛地睜開眼压状,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了槽片?” 一聲冷哼從身側(cè)響起何缓,我...
    開封第一講書人閱讀 40,167評論 0 277
  • 序言:老撾萬榮一對情侶失蹤肢础,失蹤者是張志新(化名)和其女友劉穎还栓,沒想到半個月后碌廓,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 46,698評論 1 320
  • 正文 獨居荒郊野嶺守林人離奇死亡剩盒,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 38,767評論 3 343
  • 正文 我和宋清朗相戀三年谷婆,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片辽聊。...
    茶點故事閱讀 40,912評論 1 353
  • 序言:一個原本活蹦亂跳的男人離奇死亡纪挎,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出跟匆,到底是詐尸還是另有隱情异袄,我是刑警寧澤,帶...
    沈念sama閱讀 36,572評論 5 351
  • 正文 年R本政府宣布玛臂,位于F島的核電站烤蜕,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏迹冤。R本人自食惡果不足惜讽营,卻給世界環(huán)境...
    茶點故事閱讀 42,254評論 3 336
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望泡徙。 院中可真熱鬧橱鹏,春花似錦、人聲如沸堪藐。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,746評論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽礁竞。三九已至贮勃,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間苏章,已是汗流浹背寂嘉。 一陣腳步聲響...
    開封第一講書人閱讀 33,859評論 1 274
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點兒被人妖公主榨干…… 1. 我叫王不留枫绅,地道東北人泉孩。 一個月前我還...
    沈念sama閱讀 49,359評論 3 379
  • 正文 我出身青樓,卻偏偏與公主長得像并淋,于是被迫代替她去往敵國和親寓搬。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 45,922評論 2 361