windows下安装hive2.1.1、hive3+

  • 0.简介
  • 1.解压
  • 配置文件
  • 修改 hive-env.sh
  • 修改 hive-site.xml
  • hdfs上面建立文件夹
  • 创建hive数据库,注意编码 latin1
  • 测试一下



【偷懒计划】家里的笔记本懒得开虚拟机了,开个虚拟机啊卡的要死不划算,so在windows装一个

0.简介

这里以部署2.1.1作为介绍,下载hive3.+版本后,需要加上一个步骤,就是把hive2.x版本的bin目录下哪些cmd文件拷贝到3.x版本里面去,就可以在windows下直接用了,hive3的基本配置和2.1.1差不多,不过多介绍。

1.解压

http://archive.apache.org/dist/hive 下载hive包后解压,然后新建个文件夹my_hive
如何选择hive的驱动版本 hive windows_Hive
myhive里面建几个文件夹
如何选择hive的驱动版本 hive windows_Hive_02
然后把mysql驱动丢进lib里面
如何选择hive的驱动版本 hive windows_Hive_03

配置文件

首先改名字
hive-default.xml.template -----> hive-site.xml
hive-env.sh.template -----> hive-env.sh
hive-exec-log4j.properties.template -----> hive-exec-log4j2.properties
hive-log4j.properties.template -----> hive-log4j2.properties
对了,没有hive-site的童鞋把hive-default.xml复制一份叫hive-site。xml即可
然后配置

修改 hive-env.sh

# Set HADOOP_HOME to point to a specific hadoop install directory
export HADOOP_HOME=I:\develop_software\hadoop-2.7.7

# Hive Configuration Directory can be controlled by:
export HIVE_CONF_DIR=I:\develop_software\hive\apache-hive-2.1.1-bin\conf

# Folder containing extra ibraries required for hive compilation/execution can be controlled by:
export HIVE_AUX_JARS_PATH=I:\develop_software\hive\apache-hive-2.1.1-bin\lib

修改 hive-site.xml

<!--hive的临时数据目录,指定的位置在hdfs上的目录-->
 
<property>
 
<name>hive.metastore.warehouse.dir</name>
 
<value>/user/hive/warehouse</value>
 
<description>location of default database for the warehouse</description>
 
</property>
 
 
 
<!--hive的临时数据目录,指定的位置在hdfs上的目录-->
 
<property>
 
<name>hive.exec.scratchdir</name>
 
<value>/tmp/hive</value>
 
<description>HDFS root scratch dir for Hive jobs which gets created with write all (733) permission. For each connecting user, an HDFS scratch dir: ${hive.exec.scratchdir}/<username> is created, with ${hive.scratch.dir.permission}.</description>
 
</property>
 
 
 
<!-- scratchdir 本地目录 -->
 
<property>
 
<name>hive.exec.local.scratchdir</name>
 
<value>D:/Soft/apache-hive-2.1.1-bin/my_hive/scratch_dir</value>
 
<description>Local scratch space for Hive jobs</description>
 
</property>
 
<!-- resources_dir 本地目录 -->
 
<property>
 
<name>hive.downloaded.resources.dir</name>
 
<value>D:/Soft/apache-hive-2.1.1-bin/my_hive/resources_dir/${hive.session.id}_resources</value>
 
<description>Temporary local directory for added resources in the remote file system.</description>
 
</property>
 
<!-- querylog 本地目录 -->
 
<property>
 
<name>hive.querylog.location</name>
 
<value>D:/Soft/apache-hive-2.1.1-bin/my_hive/querylog_dir</value>
 
<description>Location of Hive run time structured log file</description>
 
</property>
 
<!-- operation_logs 本地目录 -->
 
<property>
 
<name>hive.server2.logging.operation.log.location</name>
 
<value>D:/Soft/apache-hive-2.1.1-bin/my_hive/operation_logs_dir</value>
 
<description>Top level directory where operation logs are stored if logging functionality is enabled</description>
 
</property>
 
<!-- 数据库连接地址配置 -->
 
<property>
 
<name>javax.jdo.option.ConnectionURL</name>
 
<value>jdbc:mysql://localhost:3306/hive?characterEncoding=UTF-8&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>root</value>
 
<description>Username to use against metastore database</description>
 
</property>
 
<!-- 数据库访问密码 -->
 
<property>
 
<name>javax.jdo.option.ConnectionPassword</name>
 
<value>wmzycn</value>
 
<description>password to use against metastore database</description>
 
</property>
 
<!-- 解决 Caused by: MetaException(message:Version information not found in metastore. ) -->
 
<property>
 
<name>hive.metastore.schema.verification</name>
 
<value>false</value>
 
<description>
 
Enforce metastore schema version consistency.
 
True: Verify that version information stored in is compatible with one from Hive jars. Also disable automatic
 
schema migration attempt. Users are required to manually migrate schema after Hive upgrade which ensures
 
proper metastore schema migration. (Default)
 
False: Warn if the version information stored in metastore doesn't match with one from in Hive jars.
 
</description>
 
</property>
 
<!-- 自动创建全部 -->
 
<!-- hive Required table missing : "DBS" in Catalog""Schema" 错误 -->
 
<property>
 
<name>datanucleus.schema.autoCreateAll</name>
 
<value>true</value>
 
<description>Auto creates necessary schema on a startup if one doesn't exist. Set this to false, after creating it once.To enable auto create also set hive.metastore.schema.verification=false. Auto creation is not recommended for production use cases, run schematool command instead.</description>
 
</property>

hdfs上面建立文件夹

如何选择hive的驱动版本 hive windows_hive_04

如何选择hive的驱动版本 hive windows_Hive_05

创建hive数据库,注意编码 latin1

在mysql服务器上新建一个数据库叫hive

如何选择hive的驱动版本 hive windows_Hive_06


如何选择hive的驱动版本 hive windows_Hive_07


然后启动hadoop

start-all.cmd,没错,hadoop也装在windows

然后启动建表,命令: hive --service metastore

如何选择hive的驱动版本 hive windows_hive_08


看到下面这个地方的话建表就成功了

如何选择hive的驱动版本 hive windows_apache_09



如何选择hive的驱动版本 hive windows_Hive_10

测试一下

运行 hive.cmd

创建一张表

hive> create table test_table(id INT,name string);

hive> show tables;

然后在show tables后的信息打印了很多,一直拉下去,能看到test_table,那么我们就装成功辣。

如何选择hive的驱动版本 hive windows_apache_11


当然,hdfs上肯定也有了

如何选择hive的驱动版本 hive windows_如何选择hive的驱动版本_12