`

Hive: Install and basic use

    博客分类:
  • Hive
 
阅读更多
  • Install hive

1. download hive-0.12.0.bin.tar.gz

2.#tar -xzvf hive-0.12.0.bin.tar.gz

3.add the bin dir  to PATH in  ~/.bashrc

4.#source ~/.bashrc

 

The dir structure of hive-0.12.0.bin likes the following:


 

lib/ : contains JARs., which implement a particular subset of Hive's functionality.

bin/: contains executable scripts that launch various Hive service, including the hive command-line interface(CLI)

hcatalog/: metastore service related procedures.

conf/: configuration files

examples/: some example script

 

Thrift service provides remote access from other processes.

Hive uses a built-in Derby SQL server, which provides limited, single-process metadata storage.

 

start hive

#hive     //start hive CLI

#hive --help

 

The list of hive service is :

 you can start a service using command like

#hive --service  service-name

#hive        //default run CLI service

 

look for help for CLI

#hive --help --service cli

 

  •  Variables and Properties


 In CLI, set and display variables and properties using set

#hive --define foo=bar

#hive

hive> set foo;

hive>set;

hive>set -v;

hive>set env:HOME;

hive>set foo=xbar;

 

  • Basic commands

#hive --hiveconf hive.cli.print.current.db=true

 

#hive -e "select * from mytable limit 3";

#hive -S -e "select * from mytable limit 3" > /tmp/myquery;

 

execute hql script

#hive  -f /path/to/withqueries.hql

or

hive> source /path/to/withqueries.hql

 

shell execution

hive> !  shell-commands;

hive> ! pwd;

 

 note: Don't invoke interactive commands that require user input. shell 'pipes' don't work and neither do file 'globs'.

 

Hadoop dfs commands from inside hive

hive> dfs -ls /;

hive> dfs -help;

 

Comments in Hive Scripts

--the is a comment line

 

Query Column Headers

hive>set hive.cli.print.header=true;

 

Start Hive Server

#hive --service hiveserver &  //run hiveserver in daemon mode

or start hiveserver2

#hiveserver2

#netstat -nl |grep 10000        //check whether the server is running

 

 

References:

https://cwiki.apache.org/confluence/display/Hive/Home


 

  • 大小: 9.4 KB
  • 大小: 60.6 KB
  • 大小: 48 KB
  • 大小: 28.8 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics