hadoop是cdh4.2.0的版本,搭建见十分钟搭建自己的hadoop2/CDH4集群
hive版本可以是cdh4.2.0的hive-0.10.0,
下载包(win直接下载解压会失败,建议linux下wget下载)。也可以是hive-0.9.0(shark-0.7包里自带的amp实验室提供的版本)。两个版本我都尝试了,都是可以的,使用后者这个版本比较低的hive的原因是为了使用shark。
metastore则是一个mysql,只有你有mysql server,随便create 一个 空的database即可。
Hive部署
1. conf下面的hive-default等配置不需要改变,增加hive-site.xml,为其添加如下基本配置:
dir相关:
[html]
Location of Hive run time structured log file
hwi相关:
[html]
jdbc相关:
[html]
2. 在HIVE_HOME/lib下要添加mysql-driver包
3. HADOOP_HOME如果没有在环境变量里的话,请在conf/hive-env.sh里export
3. 启动hive,可以用bin/hive,但是这样报错无法定位到具体原因,建议使用
[html]
./bin/hive -hiveconf hive.root.logger=DEBUG,console
启动,特别是初次使用和建立的metastore,会遇到一些问题。
Debug Hive
bin/hive初次启动hive,执行 select tables; 可能会遇到如下错误:
[html]
FAILED: Error in metadata: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClient
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask
使用下面方式启动hive,
[html]
./bin/hive -hiveconf hive.root.logger=DEBUG,console
可能会遇到如下问题:
问题一:
[html]
Transaction level-COMMITTED' in InnoDB is not safe for binlog mode 'STATEMENT'
解决方法,用mysql登录查看hive的metastore
数据库,执行
[
html]
SET GLOBAL binlog_format = 'ROW';
参考资料:http://stackoverflow.com/questions/9665535/why-do-i-get-binary-logging-not-possible-on-my-
mysql-server
问题二:
[html]
MySQLSyntaxErrorException: Specified key was too long; max key length is 767 bytes)
解决方法,执行
[html]
alter database hive character set latin1;
参考资料:http://www.cnblogs.com/Blueren/archive/2011/06/29/Sir_001.html
如遇到其他问题,可能多数是和metastore有关,自行查阅之。
Test Hive
启动自己的hadoop dfs和yarn,启动hive,创建表:
[html]
create table test(num int, name string);
如果出错信息为:
[html]
Field 'IS_STOREDASSUBDIRECTORIES' doesn't have a default value
解决方法是去hive库里执行
[html]
ALTER