Hive: Install and basic use

本文指导您如何安装和配置Hive,包括下载、解压、添加到PATH、启动服务及CLI使用方法。
  • 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


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值