1.下载hive-0.12.0.tar.gz,解压,建符号链接hive到hive-0.12.0
2.在mysql中创建一个hive的database
3.把hive/conf/下的hive-default.xml.template改成hive-site.xml
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://hivemaster/hive?characterEncoding=UTF-8</value>
<description>JDBC connect string for a JDBC metastore</description>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
<description>Driver class name for a JDBC metastore</description>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
<description>username to use against metastore database</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>xxxx</value>
<description>password to use against metastore database</description>
</property>
4.安装libmysql-java
把/var/cache/apt/archives/libmysql-java_5.1.16-2_all.deb拷贝过来
dpkg-deb –fsys-tarfile libmysql-java_5.1.16-2_all.deb |tar xvf -
把解压出来的
mysql-connector-java.jar 拷贝到hive/lib下
运行
hive
看/tmp/hadoop/hive.log里的报错日志,是否出错。
需要追查一下原因。
需要在hive-site.xml中把metastore的schema检查去掉。
<property>
<name>hive.metastore.schema.verification</name>
<value>false</value>
<description>
Enforce metastore schema version consistency.
True: Verify that version information stored in metastore matches with one from Hive jars. Also disable automatic
schema migration attempt. Users are required to manully migrate schema after Hive upgrade which ensures
proper metastore schema migration. (Default)
False: Warn if the version information stored in metastore doesn’t match with one from in Hive jars.
</description>
</property>
5.在hdfs上建相关的目录
/user/hive/warehouse/
6.简单的使用:
t_hive.txt
16 2 3
61 12 13
41 2 31
17 21 3
71 2 31
1 12 34
11 2 34
注意中间用\t分隔
create table t_hive(a int, b int, c int) row format delimited fields terminated by ‘\t’;
创建表
load data local inpath ‘/home/hadoop/hive_soft/t_hive.txt’ overwrite into table t_hive;
加载数据
show tables;
显示表的内容
select * from t_hive;
显示表中的所有的内容