阅读 202

Hive metastore三种配置方式

Hive的meta数据支持以下三种存储方式,其中两种属于本地存储,一种为远端存储。远端存储比较适合生产环境。Hive官方wiki详细介绍了这三种方式,链接为:Hive Metastore。

 

一、本地derby
这种方式是最简单的存储方式,只需要在hive-site.xml做如下配置便可







javax.jdo.option.ConnectionURL
jdbc:derby:;databaseName=metastore_db;create=true



javax.jdo.option.ConnectionDriverName
org.apache.derby.jdbc.EmbeddedDriver



hive.metastore.local
true



hive.metastore.warehouse.dir
/user/hive/warehouse



hive.metastore.warehouse.dir
/user/hive/warehouse


注:使用derby存储方式时,运行hive会在当前目录生成 一个 derby 文件和 一个 metastore_db 目录。这种存储方式的 弊端是在同一个目录下同时只能有一个hive客户端能使用数据库,否则会提示如下错误
hive> show tables;
FAILED: Error in metadata: javax.jdo.JDOFatalDataStoreException: Failed to start database ‘metastore_db‘, see the next exception for details.
NestedThrowables:
java.sql.SQLException: Failed to start database ‘metastore_db‘, see the next exception for details.
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask
二、本地mysql
这种存储方式需要在本地运行一个mysql服务器,并作如下配置(下面两种使用mysql的方式,需要将mysql的jar包拷贝到$HIVE_HOME/lib目录下)。





hive.metastore.warehouse.dir
/user/hive_remote/warehouse



hive.metastore.local
true



javax.jdo.option.ConnectionURL
jdbc:mysql://localhost/hive_remote?createDatabaseIfNotExist=true



javax.jdo.option.ConnectionDriverName
com.mysql.jdbc.Driver



javax.jdo.option.ConnectionUserName
hive



javax.jdo.option.ConnectionPassword
password

三、远端mysql
这种存储方式需要在远端服务器运行一个mysql服务器,并且需要在Hive服务器启动meta服务。

这里用mysql的测试服务器,ip位192.168.1.214,新建hive_remote数据库,字符集位latine1







hive.metastore.warehouse.dir
/user/hive/warehouse



javax.jdo.option.ConnectionURL
jdbc:mysql://192.168.1.214:3306/hive_remote?createDatabaseIfNotExist=true



javax.jdo.option.ConnectionDriverName
com.mysql.jdbc.Driver



javax.jdo.option.ConnectionUserName
hive



javax.jdo.option.ConnectionPassword
password



hive.metastore.local
false



hive.metastore.uris
thrift://192.168.1.188:9083


注:这里把hive的服务端和客户端都放在同一台服务器上了。服务端和客户端可以拆开,将hive-site.xml配置文件拆为如下两部分

         1)、服务端配置文件






hive.metastore.warehouse.dir
/user/hive/warehouse



javax.jdo.option.ConnectionURL
jdbc:mysql://192.168.1.214:3306/hive_remote?createDatabaseIfNotExist=true



javax.jdo.option.ConnectionDriverName
com.mysql.jdbc.Driver



javax.jdo.option.ConnectionUserName
root



javax.jdo.option.ConnectionPassword
test1234

         2)、客户端配置文件






hive.metastore.warehouse.dir
/user/hive/warehouse



hive.metastore.local
false



hive.metastore.uris
thrift://192.168.1.188:9083


启动hive服务端程序

$ hive --service metastore

客户端直接使用hive命令即可

root@my188:~$ hive
Hive history file=/tmp/root/hive_job_log_root_201301301416_955801255.txt
hive> show tables;
OK
test_hive
Time taken: 0.736 seconds
hive>

————————————————
版权声明:本文为CSDN博主「reesun」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/reesun/article/details/8556078

原文:https://www.cnblogs.com/javalinux/p/14902809.html

文章分类
代码人生
版权声明:本站是系统测试站点,无实际运营。本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 XXXXXXo@163.com 举报,一经查实,本站将立刻删除。
相关推荐