hive安装(内嵌模式,采用Hive的默认源数据库,即内嵌的Derby)

一、相关文件配置

1、版本说明

hadoop3.1.3   ~  hive3.1.2

2、解压hive压缩包

tar  -zvxf   apache-hive-3.1.0-bin.tar.gz

3、相关文件配置

3.1    用户目录下.bashrc文件配置

#HIVE
export HIVE_HOME=/home/WBQ/soft/apache-hive-3.1.2-bin
export PATH=$PATH:$HIVE_HOME/bin

3.2     hive-env.sh文件配置(需要修改对应的路径)

# 在该文件中加入以下代码
export HADOOP_HOME=/home/WBQ/soft/hadoop-3.1.3
export HIVE_CONF_DIR=/home/WBQ/soft/apache-hive-3.1.2-bin/conf
export JAVA_HOME=$JAVA_HOME
export HIVE_HOME=$HIVE_HOME

3.3     hive-site.xml文件配置(全部照搬即可)

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<!--JDBC连接字符串,默认jdbc:derby:;databaseName=metastore_db;create=true;-->
<property>
  <name>javax.jdo.option.ConnectionURL</name>
  <value>jdbc:derby:;databaseName=metastore_db;create=true</value>
</property>

<!--JDBC的driver,默认org.apache.derby.jdbc.EmbeddedDriver-->
<property>
  <name>javax.jdo.option.ConnectionDriverName</name>
  <value>org.apache.derby.jdbc.EmbeddedDriver</value>
</property>


<!---使用本地服务连接Hive,默认为true-->
<property>
  <name>hive.metastore.local</name>
  <value>true</value>
</property>

<!--关闭版本验证-->
<property>
  <name>hive.metastore.schema.verification</name>
  <value>false</value>
</property>

<!--Hive产生的元数据存放位置-->
<property>
  <name>hive.metastore.warehouse.dir</name>
  <value>/user/hive/warehouse</value>
</property>

<!--当元数据库中必要的数据对象不存在是,会自动创建-->
<property>
    <name>datanucleus.schema.autoCreateAll</name>
    <value>true</value>
</property>
</configuration>

2.4 修改配置文件hive-log4j2.properties.template

cp   hive-log4j2.properties.template   hive-log4j2.properties
​vi   hive-log4j2.properties

在该文件中修改以下内容,其中logs为自己新建的文件夹

# property.hive.log.dir = ${sys:java.io.tmpdir}/${sys:user.name}
property.hive.log.dir = /home/WBQ/soft/apache-hive-3.1.2-bin/logs

2.5 配置源数据MySQL数据库,放到${HIVE_HOME}/lib目录下

下载  mysql-connector-java-5.1.47.jar并将其放到${HIVE_HOME}/lib目录下。

资源获取:百度网盘

提取码:6666

二、hive安装目录下执行下面命令初始化hive

(默认数据库为derby)

1、初始化命令为:

schematool -dbType derby -initSchema

2、初始化日志如下:

[WBQ@westgisB064 conf]$ schematool -dbType derby -initSchema
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/WBQ/soft/apache-hive-3.1.2-bin/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/WBQ/soft/hadoop-3.1.3/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Metastore connection URL:	 jdbc:derby:;databaseName=metastore_db;create=true
Metastore Connection Driver :	 org.apache.derby.jdbc.EmbeddedDriver
Metastore connection User:	 APP
Starting metastore schema initialization to 3.1.0
Initialization script hive-schema-3.1.0.derby.sql

Initialization script completed
schemaTool completed
[WBQ@westgisB064 conf]$

三、验证

1、启动集群($HADOOP_HOME/sbin/start-dfs.sh)

[WBQ@westgisB064 conf]$ $HADOOP_HOME/sbin/start-dfs.sh
Starting namenodes on [westgisB064]
Starting datanodes
Starting secondary namenodes [westgisB064]
[WBQ@westgisB064 conf]$

2、关闭集群安全模式

[WBQ@westgisB064 conf]$ hadoop dfsadmin -safemode leave
WARNING: Use of this script to execute dfsadmin is deprecated.
WARNING: Attempting to execute replacement "hdfs dfsadmin" instead.

Safe mode is OFF
[WBQ@westgisB064 conf]$

3、启动hive

[WBQ@westgisB064 conf]$ hive
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/WBQ/soft/apache-hive-3.1.2-bin/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/WBQ/soft/hadoop-3.1.3/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Hive Session ID = 08364f8a-1fbf-4696-bd01-1219cf72a9bc

Logging initialized using configuration in file:/home/WBQ/soft/apache-hive-3.1.2-bin/conf/hive-log4j2.properties Async: true
2023-06-02 21:19:32,203 INFO  [08364f8a-1fbf-4696-bd01-1219cf72a9bc main] DataNucleus.Persistence: Property datanucleus.cache.level2 unknown - will be ignored
2023-06-02 21:19:34,131 WARN  [08364f8a-1fbf-4696-bd01-1219cf72a9bc main] DataNucleus.MetaData: Metadata has jdbc-type of null yet this is not valid. Ignored
2023-06-02 21:19:34,131 WARN  [08364f8a-1fbf-4696-bd01-1219cf72a9bc main] DataNucleus.MetaData: Metadata has jdbc-type of null yet this is not valid. Ignored
2023-06-02 21:19:34,132 WARN  [08364f8a-1fbf-4696-bd01-1219cf72a9bc main] DataNucleus.MetaData: Metadata has jdbc-type of null yet this is not valid. Ignored
2023-06-02 21:19:34,132 WARN  [08364f8a-1fbf-4696-bd01-1219cf72a9bc main] DataNucleus.MetaData: Metadata has jdbc-type of null yet this is not valid. Ignored
2023-06-02 21:19:34,132 WARN  [08364f8a-1fbf-4696-bd01-1219cf72a9bc main] DataNucleus.MetaData: Metadata has jdbc-type of null yet this is not valid. Ignored
2023-06-02 21:19:34,132 WARN  [08364f8a-1fbf-4696-bd01-1219cf72a9bc main] DataNucleus.MetaData: Metadata has jdbc-type of null yet this is not valid. Ignored
2023-06-02 21:19:35,665 WARN  [08364f8a-1fbf-4696-bd01-1219cf72a9bc main] DataNucleus.MetaData: Metadata has jdbc-type of null yet this is not valid. Ignored
2023-06-02 21:19:35,666 WARN  [08364f8a-1fbf-4696-bd01-1219cf72a9bc main] DataNucleus.MetaData: Metadata has jdbc-type of null yet this is not valid. Ignored
2023-06-02 21:19:35,666 WARN  [08364f8a-1fbf-4696-bd01-1219cf72a9bc main] DataNucleus.MetaData: Metadata has jdbc-type of null yet this is not valid. Ignored
2023-06-02 21:19:35,666 WARN  [08364f8a-1fbf-4696-bd01-1219cf72a9bc main] DataNucleus.MetaData: Metadata has jdbc-type of null yet this is not valid. Ignored
2023-06-02 21:19:35,666 WARN  [08364f8a-1fbf-4696-bd01-1219cf72a9bc main] DataNucleus.MetaData: Metadata has jdbc-type of null yet this is not valid. Ignored
2023-06-02 21:19:35,666 WARN  [08364f8a-1fbf-4696-bd01-1219cf72a9bc main] DataNucleus.MetaData: Metadata has jdbc-type of null yet this is not valid. Ignored
2023-06-02 21:19:38,744 WARN  [08364f8a-1fbf-4696-bd01-1219cf72a9bc main] DataNucleus.Datastore: SQL Warning : 'UNIQUEDATABASE' index not created because it is a duplicate of an existing index: 'UNIQUE_DATABASE'.
Hive Session ID = b1c939dd-f596-442d-9b9b-9c5367d1b206
Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.
hive> 

4、创建数据库

hive> show databases;
OK
default
Time taken: 0.733 seconds, Fetched: 1 row(s)
hive> create schema one;
OK
Time taken: 0.114 seconds
hive> show databases;
OK
default
one
Time taken: 0.028 seconds, Fetched: 2 row(s)
hive>

5、建表

hive> create table student(id int, name string, sex string, age int,department string) row format delimited fields terminated by ",";
OK
Time taken: 0.582 seconds
hive> desc student;
OK
id                  	int                 	                    
name                	string              	                    
sex                 	string              	                    
age                 	int                 	                    
department          	string              	                    
Time taken: 0.212 seconds, Fetched: 5 row(s)
hive> 

6、验证无报错,退出

 hive>quit;

7、关闭集群

$HADOOP_HOME/sbin/stop-dfs.sh

  查看集群是否已关闭

[WBQ@westgisB064 ~]$ ps aux|grep java
WBQ      24756  0.0  0.0 112712   980 pts/0    S+   22:12   0:00 grep --color=auto java
[WBQ@westgisB064 ~]$
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值