hive搭建之嵌入模式
hive是基于hdfs和yarn平台的,所以在搭建之前先把hadoop搭建起来
什么是hive的嵌入模式
我认为hive的嵌入模式就是它使用的创建元信息的数据库是嵌入到hive中的derby数据
配置
- 先把下载好的tar.gz包解压
- 解压我们需要配置一个用户的环境变量
3.然后在配置一个配置文件
cd /root/training/apache-hive-3.1.2-bin/conf
touch hive-site.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:derby:;databaseName=metastore_db;create=true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>org.apache.derby.jdbc.EmbeddedDriver</value>
</property>
<property>
<name>hive.metastore.local</name>
<value>true</value>
</property>
<!--Hive数据存储的路径-->
<property>
<name>hive.metastore.warehouse.dir</name>
<value>file:///root/training/apache-hive-3.1.2-bin/warehouse</value>
</property>
</configuration>
配置完毕后需要初始化一下derby数据库,创建一下表到derby数据库中,用来保存hive表的元信息
初始化MetaStore:
schematool -dbType derby -initSchema
有一个注意的地方就是在哪儿执行的初始化必须在哪儿启动hive命令
不然的话会报错
2020-04-24 19:33:32,348 WARN [bf878359-3dd0-4e08-a877-57bcd639c8b6 main] DataNucleus.Query: Query for candidates of org.apache.hadoop.hive.metastore.model.MVersionTable and subclasses resulted in no possible candidates
Required table missing : "VERSION" in Catalog "" Schema "". DataNucleus requires this table to perform its persistence operations. Either your MetaData is incorrect, or you need to enable "datanucleus.schema.autoCreateTables"
org.datanucleus.store.rdbms.exceptions.MissingTableException: Required table missing : "VERSION" in Catalog "" Schema "". DataNucleus requires this table to perform its persistence operations. Either your MetaData is incorrect, or you need to enable "datanucleus.schema.autoCreateTables"
测试:
启动hive命令行,在初始化的地方执行hive命令就可以了
然后执行create table student(sid int,sname string,sage int)进行创建表测试
然后执行insert into student values(1,"Lily",13);
然后在查询select * from student;
也可以去配的warhourse中查看
因为一边用不到嵌入模式,所以了解就可以了!