windows 下 Hive 搭建踩坑汇总
前言:
Hive 是一个基于 Hadoop 的数据仓库工具,以一种类 SQL 的 HQL 语句操作 Hadoop 数据仓库(HDFS 等)。所以本地 windows 安装前需要先搭建 Hadoop。前面文章已经大概介绍了环境搭建和踩坑汇总,所以这里也依旧只是介绍基础的安装方法。因为关于 Hive 的安装,网上其实有很多文章,这里更多的是小北在安装过程中的遇到的各种坑的汇总以及解决方法。
环境:
\1. windows10
\2. hadoop2.7.7
\3. mysql-connector-java-5.1.7-bin.jar
\4. hive2.1.1,点击下载
简易安装:
1. Hadoop 本地搭建,略过。
2. Hive 下载安装,环境变量配置,略过。
3. Hive config 配置。
(1). 找到 hive 的 conf 下的以下四个文件再按下面方式修改。

4. 创建目录。
(1). 先将 mysql-connector-java-5.1.7-bin.jar 文件移动到 hive 的 lib 中,如下。

(2). 现在 hive 根目录下创建一个 my_hive 再创建以下四个目录。

5. 修改 hive-env.sh
(1). 找到 hive 的 conf 下的 hive-env.sh 并添加以下几个配置。

6. 修改 hive-site.xml
(1). 找到 hive 的 conf 下的 hive-site.xml。
(2). 修改以下几个选项。
7. 在 Hadopp 上创建 HDFS 目录
(1). 创建以下目录并授予 777 权限。


(2). 在 hadoop 控制台上查看。

8. 创建 MySQL 数据库
(1). 创建 hive 数据库,可以以命令或者 navicat 方式创建。

9. 启动 Hive metastore
(1). 安装完毕只需要启动一次,启动后 Mysql 的 hive 数据库会多出以下表格。

10. 启动 hive
(1). 如果配置了 hive 环境变量,如果没有则进入 hive 目录的 bin 文件下,输入 hive。
(2). 启动成功没有报错,示例创建一张表格,输入以下 HQL 语句创建。
(3). 进入 hadoop 的控制台就可以查看了。

11. HQL 几个常见命令
报错集锦
1. HiveConf of name hive.metastore.local does not exist
去除hive.metastore.localtrue
2. Version information not found in metastore. hive.metastore.schema.verification is not enabled so recording the schema version 2.1.0
在 hive 数据库的 version 添加一条记录,如下

3. applying authorization policy on hive configuration: java.net.URISyntaxException: Relative path in absolute URI: {system:java.io.tmpdir%7D/%7Bsystem:user.name%7D Beeline version 2.1.1 by Apache Hive
打开 hive-site.xml,找到 hive.exec.local.scratchdir, 将带有 system:的标识全部去掉,如下

4. hadoop 的 web 控制台文件系统,打开某个目录报错: Permission denied: user=dr.who, access=READ_EXECUTE, inode="/tmp/hive/Administrator":Administrator:supergroup:drwx------
进入 hadoop 命令,输入 hadoop fs -chmod 777 /tmp/hive

附
Default 数据仓库默认位置:hdfs 上的:/user/hive/warehouse 路径下

评论