hive 用mysql存储元信息

http://www.tech126.com/hive-mysql-metastore/

Hive默认是采用Derby来存储其Meta信息的,如下:

< property>
 
< name> javax. jdo. OPTION . ConnectionURL</ name>
 
< value> jdbc:derby:// zw- hadoop- master:1527 / metastore_db;create= true</ value>
 
< description> JDBC connect string FOR a JDBC metastore</ description>
 
</ property>
 
 
< property>
 
< name> javax. jdo. OPTION . ConnectionDriverName</ name>
 
< value> org. apache. derby. jdbc. ClientDriver</ value>
 
< description> Driver class name FOR a JDBC metastore</ description>
 
</ property>



我们可以修改一下配置,让Mysql来存储其Meta信息

首先,在Mysql服务器上建立相应的库,并赋权限

create database hivedb;

grant all privileges on hivedb.* to hiveuser@'%' identified by 'hiveuser';

grant all privileges on hivedb.* to hiveuser@'localhost' identified by 'hiveuser';

然后,把mysql-connector-java-5.1.12-bin.jar拷贝到/cq/hive/lib下  //注意这里要从mysql官网下connector的包,不然可能出错

再修改hive-default.xml配置

< property>
 
< name> javax. jdo. OPTION . ConnectionURL</ name>
 
< value> jdbc:mysql:// 192. 168. 95. 25:3306 / hivedb?createDatabaseIfNotExist= true</ 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> hiveuser</ value>
 
< description> username TO USE against metastore database</ description>
 
</ property>
 
< property>
 
< name> javax. jdo. OPTION . ConnectionPassword</ name>
 
< value> hiveuser</ value>
 
< description> password TO USE against metastore database</ description>
 
</ property>

 

你可能感兴趣的:(apache,hadoop,mysql,jdbc,Derby)