- 下载
cd /data0/software/hive
wget http://mirror.bit.edu.cn/apache/hive/hive-0.12.0/hive-0.12.0-bin.tar.gz
另一个hive-0.12.0.tar.gz,里面有docs和src文件夹 - 解压
tar zxvf /data0/software/hive/hive-0.12.0-bin.tar.gz -C /home/app/act/hive/
ln -s /home/app/act/hive/hive-0.12.0 /home/app/srv/hive - 配置环境变量
export HIVE_HOME=/home/app/srv/hive
export PATH=$PATH:$HIVE_HOME/bin
export CLASSPATH=$CLASSPATH:$HIVE_HOME/lib - 配置配置文件
- hive-env.sh
配置HADOOP_HOME=/home/app/srv/hadoop
- cd /home/app/srv/hive/conf/
cp hive-default.xml hive-site.xml
修改:
<name>javax.jdo.option.ConnectionURL</name>
<!--<value>jdbc:derby:;databaseName=metastore_db;create=true</value> -->
<value>jdbc:mysql://10.1.16.2:3306/hive?createDatabaseIfNotExist=true</value>
<description>JDBC connect string for a JDBC metastore</description>
</property>
默认使用enbed方式,元数据保存在Derby中,只允许一个会话连接;
远程模式:元数据放置在远程mysql
本地模式:元数据放置在本地mysql修改到mysql,添加
jdbc:mysql://<ip>:3306/hive?createDatabaseIfNotExist=true<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>hive</value>
<description>username to use against metastore database</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>hive</value>
<description>password to use against metastore database</description>
</property> - 启动
帮助模式: hive --help显示hive支持的类型
Usage ./hive <parameters> --service serviceName <service parameters>
Service List: beeline cli help hiveserver2 hiveserver hwi jar lineage metastore metatool orcfiledump rcfilecat schemaTool
Parameters parsed:
--auxpath : Auxillary jars
--config : Hive configuration directory
--service : Starts specific service/component. cli is default
Parameters used:
HADOOP_HOME or HADOOP_PREFIX : Hadoop install directory
HIVE_OPT : Hive options
For help on a particular service:
./hive --service serviceName --help
Debug help: ./hive --debug --help
hive --service help显示支持的服务类型
Usage ./hive <parameters> --service serviceName <service parameters>Service List: beeline cli help hiveserver2 hiveserver hwi jar lineage metastore metatool orcfiledump rcfilecat schemaTool
Parameters parsed:
--auxpath : Auxillary jars
--config : Hive configuration directory
--service : Starts specific service/component. cli is default
Parameters used:
HADOOP_HOME or HADOOP_PREFIX : Hadoop install directory
HIVE_OPT : Hive options
For help on a particular service:
./hive --service serviceName --help
Debug help: ./hive --debug --help
启动脚本app@H1:~/srv/hive/bin$ cat hive-metastore.sh
#!/bin/sh
nohup /home/app/srv/hive/bin/hive --service metastore >> /tmp/metastore.log 2>&1 &
echo $! > /tmp/hive-metastore.pidapp@H1:~/srv/hive/bin$ cat hive-server.sh
#!/bin/sh
nohup /home/app/srv/hive/bin/hive --service hiveserver >> /tmp/hiveserver.log 2>&1 &
echo $! > /tmp/hive-server.pid - 数据操作,hive的数据来源于hadoop的hdf,先要将数据put到hdf
1. 创建一个普通文件aa.txt
2.hadoop dfs -put './aa.txt' '/user/app/testinput/‘
3.hive ==》进入hive交互命令行
create database test;
use test;
create table test1 (id int, name string );
LOAD DATA Local INPATH '/user/app/testinput/aa.txt' OVERWRITE INTO TABLE test;
select * from test;
drop table test;
https://cwiki.apache.org/confluence/display/Hive/GettingStarted
https://cwiki.apache.org/confluence/display/Hive/AdminManual+MetastoreAdmin