Hive-1.2.0 Learning Note (iii) Hive user interface

Source: Internet
Author: User

Ruchunli's work notes , who says programmers can't have a literary fan?


Hive provides three service modes externally, the CLI (command line interface), Hive Web, and hive Client (such as JAVAAPI).


1. Hive command line mode (CLI)

There are two ways to start hive command-line mode

Bin/hive or bin/hive--service CLI


Hive Command Options

[[email protected] hive1.2.0]$ bin/hive --helpusage ./hive <parameters>  --service servicename <service parameters>service list: beeline cli  help hiveburninclient hiveserver2 hiveserver hwi jar lineage  metastore metatool orcfiledump rcfilecat schematool version #  here corresponds to hive The  <parameters> parameter parameters parsed:  #  allows the user to specify a colon-separated companion jar package, such as a custom extension.   --auxpath : Auxillary jars   #  Specify the file directory, overriding the default property configuration in $hive_home/conf   --config : Hive configuration directory  #  services that need to be started, default to CLI, See other SERVICE&NBSP;LIST:&NBSP;&NBSP;--SERVICE&NBSP;:&NBSP;STARTS&NBSP;SPECIFIC&NBSP;SERVICE/COMPONENT.&NBSP;CLI  is defaultParameters used:  HADOOP_HOME or HADOOP_PREFIX :  Hadoop install directory  hive_opt : hive optionsfor help on a particular service: #  Help for querying a specific service name   ./hive --service servicename --helpdebug help:  ./hive  --debug --help##  using the version service [[email protected] hive1.2.0]$ bin/hive -- Service versionhive 1.2.0subversion git://localhost.localdomain/home/sush/dev/hive.git -r  7f237de447bcd726bb3d0ba332cbb733f39fc02fcompiled by sush on thu may 14  18:00:25 PDT 2015From source with checksum  03a73b649153ba8e11467a779def6315[[email protected] hive1.2.0]$ ##  execution--service does not follow any parameters [[email  protected] hive1.2.0]$ bin/hive --service equivalent to BIN/HIVE&NBSP;--SERVICE&NBSP;CLI

The service list includes the vast majority of the CLI that will be used, which can be started by the--service name Service name, which is the default boot CLI. Note that individual services have actually provided a quick-start approach.

Common services are as follows:

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/77/B3/wKioL1ZsJvPyKburAAHnQWnG3Pg622.jpg "title=" Qq20151212215329.jpg "alt=" Wkiol1zsjvpykburaahnqwng3pg622.jpg "/>


Hive CLI Command Parameters

[[Email protected] hive1.2.0]$ bin/hive --verbose --helpusage: hive -d,-- define <key=value>                Define the parameters used by the hive command line, such as-d a=b or --define a=b --database <databasename>              Specify the database to use  -e < quoted-query-string>              Execute SQL statements from the command line  -f <filename>                          Execute SQL statement in file  -h,--help                               Show Help  --hiveconf <property=value>            a given parameter value overrides the parameter value in Hive-default.xml or Hive-site.xml  --hivevar <key=value>                  define variables that are applied to hive, such as--hivevar a= B (equivalent to-D)  -i <filename>                          initialized SQL file  -s,--silent                             static mode (no output)  -v,--verbose                           Verbose mode [[email protected] hive1.2.0]$##  such as #hive -e  "" #hive  -e  "" >aaa#hive  -S -e  "" >aaa#hive -e  ' select a.col from tab1 a '   #hive  -f hdfs://<namenOde>:<port>/hive-script.sql#hive -i /home/my/hive-init.sql#hive>source file#hive >!ls            #  using the shell command #hive>dfs  -ls /      #  using the Hdfs dfs command (omit HDFs)


Variable or property

In the CLI, the value of a variable can be displayed or modified through the SET command, or it can be specified through the command space.

Set Operation Example

Hive> Set env:home;env:home=/home/hadoophive> Set env:hive_home;env:hive_home=/usr/local/hive1.2.0hive>

The command space is specified in the form

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/77/B3/wKioL1ZsKOPQxwJIAAEGGhQ1JYs475.jpg "title=" Qq20151212220149.jpg "alt=" Wkiol1zskopqxwjiaaegghq1jys475.jpg "/>


Example code:

#hive  --hivevar column=name#hive --hiveconf hive.cli.print.current.db=true  Hive.cli.print.header=true#system: java defines the configuration properties, such as System:user.name (that is, the contents of the system's properties) #env: Shell environment variables, such as Env:user, Env. hive_home##  verifying Hivevar, System, env[[email protected] hive1.2.0]$ hive --hivevar  Column=namehive> create table test (id int, ${hivevar:column} string, ${ system:user.name} string, path string);oktime taken: 1.687 secondshive>  Insert into table test values (1000,  ' Lisi ',  ' root ',  ' ${env:home} ');#  The MapReduce process is slightly hive> set hive.cli.print.header=true;    #  displayed headerhive>  select * from test;OKtest.id test.name        test.hadoop     test.path    #  gets the value of the variable 1000     lisi            root             /home/hadoop    Time taken: 0.147  Seconds, fetched: 1 row (s) hive> ##  authentication hiveconf [[email protected]  hive1.2.0]$ hive --hiveconf hive.cli.print.current.db=truehive  (default) > use  mywork;OKTime taken: 1.089 secondshive  (mywork) > set  hive.cli.print.header=true;hive  (mywork) > select eno, ename from employee;o keno     ename1000    zhangsantime taken: 0.223  Seconds, fetched: 1 row (s) hive  (mywork) >


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/77/B3/wKioL1ZsKDCAYeeCAACkzKN4bl0194.jpg "title=" Qq20151212215839.jpg "alt=" Wkiol1zskdcayeecaackzkn4bl0194.jpg "/>


2. Hive Web Mode

Start the HWI service with a service

[Email protected] hive1.2.0]$ bin/hive--service hwils:cannot access/usr/local/hive1.2.0/lib/hive-hwi-*.war:no such F Ile or Directory15/12/12 22:30:08 INFO hwi. Hwiserver:hwi is starting UP15/12/12 22:30:10 INFO mortbay.log:Logging to Org.slf4j.impl.Log4jLoggerAdapter ( Org.mortbay.log) via ORG.MORTBAY.LOG.SLF4JLOG15/12/12 22:30:10 info MORTBAY.LOG:JETTY-6.1.2615/12/12 22:30:11 Info mortbay.log:Started [email protected]:9999[[email protected] hive1.2.0]$

The Hwi War file does not exist, and it is not possible to find the Hwi War file when viewed through the Find command, using the file in the Hwi/web directory under SRC to be processed as a war packet:

E:\hive\apache-hive-1.2.0-src\hwi\web>jar CVF Hive-hwi-1.2.0.war./*

and upload the war file to the $hive_home/lib directory and modify the configuration parameters of the HWI through the configuration file (Hive-site.xml)

<property>    <name>hive.hwi.listen.host</name>     <value>nnode</value>    <description>this is the host  address the Hive Web Interface will listen on</description>< /property><property>    <name>hive.hwi.listen.port</name>     <value>9999</value>    <description>this is the  port the hive web interface will listen on</description></ property><property>    <name>hive.hwi.war.file</name>     <value>lib/hive-hwi-1.2.0.war</value>    <description>this  sets the path to the hwi war file, relative to ${hive_ Home}.</description></property> 

Start the HWI service again and access it through the web

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/77/B4/wKioL1ZsPa6jHRcEAAII2Kffd6o043.jpg "title=" Qq20151212232026.jpg "alt=" Wkiol1zspa6jhrceaaii2kffd6o043.jpg "/>

In fact, Tools.jar has been added to the classpath path, there is no way, only the JDK path under the Tools.jar copy to the Lib directory hive, and then again through the hive--service hwi boot, after the boot access, OK.

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/77/B5/wKiom1ZsPfyy3aaRAAIUa5DWGG0245.jpg "title=" Qq20151212231953.jpg "alt=" Wkiom1zspfyy3aaraaiua5dwgg0245.jpg "/>


3. Remote service of Hive





This article is from the "world of Stuffy Gourd" blog, please be sure to keep this source http://luchunli.blog.51cto.com/2368057/1722348

Hive-1.2.0 Learning Note (iii) Hive user interface

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.