下载hive 0.13.1 解压
在etc/profile里配置环境变量
修改hive/conf下配置文件
#hive-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>hdfs://101.200.200.114:9008/hive/warehouse</value>#hdfs下的目录
<description>location of default database for the warehouse</description>
</property>
#存放hive相关日志的目录
<property>
<name>hive.querylog.location</name>
<value>/usr/local/hadoop/apache-hive-0.13.1-bin/yj_data/log</value>#需要自己手动创建对应目录
<description>
Location of Hive run time structured log file
</description>
</property>
<!--
<property>
<name>hive.metastore.uris</name>
<value>10000</value>
</property>
-->
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://101.200.200.114:3306/db_hive</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>root</value>
</property>
</configuration>
#hive-env.sh
export HADOOP_HEAPSIZE=1024
HADOOP_HOME=/usr/local/hadoop/hadoop-1.2.1
export HIVE_CONF_DIR=/usr/local/hadoop/apache-hive-0.13.1-bin/conf
export HIVE_AUX_JARS_PATH=/usr/local/hadoop/apache-hive-0.13.1-bin/lib
rz mysql驱动到hive/lib下
创建表
create table cite(citing INT, cited INT) row format delimited fields terminated by ',' stored as textfile;
show tables;
describe cite;
下载数据http://www.nber.org/patents/
导入数据
load data local inpath '/home/xuqiang/hadoop/data/cite75_99.txt'
> overwrite into table cite;
select * from cite limit 10;
select count(1) from cite;
drop table cite;