Install Hive

一、Hive将元数据存储在RDBMS中,有三种模式可以连接到数据:

1、single User Mode:此模式连接到一个In-memory的数据库Derby,一般用于Unit Test。

2、Multi User Mode:通过网络连接到一个数据库中,是最经常使用到的模式。

3、Remote Server Mode:用于非Java客户端访问元数据库,在服务器端启动一个MetaStoreServer,客户端利用Thrift协议通过MetaStoreServer访问元数据库。

二、暂略

三、暂略

四、MySQL做元数据库模式

1、解压hive的压缩包

2、把mysql-connector-java-5.1.10-bin.jar包复制到hive的lib目录下

[hadoop@node3 lib]$ ll mysql-connector-java-5.1.10-bin.jar 
-rw-r--r-- 1 root root 724225 Sep 17 17:03 mysql-connector-java-5.1.10-bin.jar
[hadoop@node3 lib]$ pwd
/app/hive/lib

3、配置hive

----将hive-default.xml.template拷贝成hive-site.xml
----修改hive-site.xml文件
----添加、修改如下信息:
----Mysql连接
<property>
  <name>javax.jdo.option.ConnectionURL</name>
  <value>jdbc:mysql://192.168.1.152:3306/jack?createDatabaseIfNotExist=true</value>
  <description>JDBC connect string for a JDBC metastore</description>
</property>

----Mysql连接驱动:
<property>
  <name>javax.jdo.option.ConnectionDriverName</name>
  <value>com.mysql.jdbc.Driver</value>
  <description>Driver class name for a JDBC metastore</description>
</property>

----登陆Mysql的用户名:
<property>
  <name>javax.jdo.option.ConnectionUserName</name>
  <value>jack</value>
  <description>username to use against metastore database</description>
</property>

----登陆Mysql的用户jack的密码:
<property>
  <name>javax.jdo.option.ConnectionPassword</name>
  <value>jack</value>
  <description>password to use against metastore database</description>
</property>

----指定本地登陆mysql还是远程:(我这里是远程)
<property>
  <name>hive.metastore.local</name>
  <value>false</value>
  <description>controls whether to connect to remove metastore server or open a new metastore server in Hive Client JVM</description>
</property>

----Hive表数据存放目录,自带默认值:
<property>
  <name>hive.metastore.warehouse.dir</name>
  <value>/user/hive/warehouse</value>
  <description>location of default database for the warehouse</description>
</property>

----Hive临时文件存放目录,使用默认值即可:
<property>
  <name>hive.exec.scratchdir</name>
  <value>/tmp/hive-${user.name}</value>
  <description>Scratch space for Hive jobs</description>
</property>

4、安装配置mysql并且创建jack的用户和数据库

5、最后对hive进行测试

五、hive的元数据存储在mysql后,报错的解决方法

当在hive中drop table 时如果报以下错时

   FAILED: Error in metadata: javax.jdo.JDODataStoreException: Error(s) were found while auto-creating/validating the datastore for classes. The errors are printed in the log, and are attached to this exception.
NestedThrowables:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Specified key was too long; max key length is 767 bytes
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask

解决的方法是到mysql中的hive数据库里执行 alter database hive character set latin1;改变Hive元数据库的字符集。

posted @ 2013-09-22 11:47  I’m Me!  阅读(1126)  评论(0编辑  收藏  举报