Window 安装Hive

8 篇文章 0 订阅
本文详细指导了在Windows 10环境下安装Hadoop 2.7.x,下载并配置Hive 2.1.1,设置环境变量,修改关键配置如元数据目录和资源路径,并解决Hive初始化问题。最后演示了如何创建Hive数据库和启动服务的过程。
摘要由CSDN通过智能技术生成

基本环境资源

Hadoop:2.7.X

Hive:2.1.X.bin.tar.gz 版本

Hive:1.x.src.tar.gz 源码版本

第一步:windows 安装Hadoop2.7.x,请参考:

第二步:下载Hive.tar.gz,官网下载地址:http://archive.apache.org/dist/hive

第二步:解压Hive.tar.gz 至指定文件夹目录(C:\hive),配置Hive 全局环境变量。

Hive 全局环境变量:

第三步:Hive 配置文件(C:\hive\apache-hive-2.1.1-bin\conf)

配置文件目录C:\hive\apache-hive-2.1.1-bin\conf\conf有4个默认的配置文件模板拷贝成新的文件名

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
 

第四步: 新建本地目录后面配置文件用到

C:\hive\apache-hive-2.1.1-bin\my_hive

第五步:Hive需要调整的配置文件(hive-site.xml 和hive-env.sh)

编辑C:\hive\apache-hive-2.1.1-bin\conf\conf\hive-site.xml 文件


  
  
  1. <!--hive的临时数据目录,指定的位置在hdfs上的目录-->
  2. <property>
  3. <name>hive.metastore.warehouse.dir </name>
  4. <value>/user/hive/warehouse </value>
  5. <description>location of default database for the warehouse </description>
  6. </property>
  7. <!--hive的临时数据目录,指定的位置在hdfs上的目录-->
  8. <property>
  9. <name>hive.exec.scratchdir </name>
  10. <value>/tmp/hive </value>
  11. <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}/ &lt;username &gt; is created, with ${hive.scratch.dir.permission}. </description>
  12. </property>
  13. <!-- scratchdir 本地目录 -->
  14. <property>
  15. <name>hive.exec.local.scratchdir </name>
  16. <value>C:/hive/apache-hive-2.1.1-bin/my_hive/scratch_dir </value>
  17. <description>Local scratch space for Hive jobs </description>
  18. </property>
  19. <!-- resources_dir 本地目录 -->
  20. <property>
  21. <name>hive.downloaded.resources.dir </name>
  22. <value>C:/hive/apache-hive-2.1.1-bin/my_hive/resources_dir/${hive.session.id}_resources </value>
  23. <description>Temporary local directory for added resources in the remote file system. </description>
  24. </property>
  25. <!-- querylog 本地目录 -->
  26. <property>
  27. <name>hive.querylog.location </name>
  28. <value>C:/hive/apache-hive-2.1.1-bin/my_hive/querylog_dir </value>
  29. <description>Location of Hive run time structured log file </description>
  30. </property>
  31. <!-- operation_logs 本地目录 -->
  32. <property>
  33. <name>hive.server2.logging.operation.log.location </name>
  34. <value>C:/hive/apache-hive-2.1.1-bin/my_hive/operation_logs_dir </value>
  35. <description>Top level directory where operation logs are stored if logging functionality is enabled </description>
  36. </property>
  37. <!-- 数据库连接地址配置 -->
  38. <property>
  39. <name>javax.jdo.option.ConnectionURL </name>
  40. <value>jdbc:mysql://192.168.60.178:3306/hive?serverTimezone=UTC &amp;useSSL=false &amp;allowPublicKeyRetrieval=true </value>
  41. <description>
  42. JDBC connect string for a JDBC metastore.
  43. </description>
  44. </property>
  45. <!-- 数据库驱动配置 -->
  46. <property>
  47. <name>javax.jdo.option.ConnectionDriverName </name>
  48. <value>com.mysql.cj.jdbc.Driver </value>
  49. <description>Driver class name for a JDBC metastore </description>
  50. </property>
  51. <!-- 数据库用户名 -->
  52. <property>
  53. <name>javax.jdo.option.ConnectionUserName </name>
  54. <value>admini </value>
  55. <description>Username to use against metastore database </description>
  56. </property>
  57. <!-- 数据库访问密码 -->
  58. <property>
  59. <name>javax.jdo.option.ConnectionPassword </name>
  60. <value>123456 </value>
  61. <description>password to use against metastore database </description>
  62. </property>
  63. <!-- 解决 Caused by: MetaException(message:Version information not found in metastore. ) -->
  64. <property>
  65. <name>hive.metastore.schema.verification </name>
  66. <value>false </value>
  67. <description>
  68. Enforce metastore schema version consistency.
  69. True: Verify that version information stored in is compatible with one from Hive jars. Also disable automatic
  70. schema migration attempt. Users are required to manually migrate schema after Hive upgrade which ensures
  71. proper metastore schema migration. (Default)
  72. False: Warn if the version information stored in metastore doesn't match with one from in Hive jars.
  73. </description>
  74. </property>
  75. <!-- 自动创建全部 -->
  76. <!-- hive Required table missing : "DBS" in Catalog""Schema" 错误 -->
  77. <property>
  78. <name>datanucleus.schema.autoCreateAll </name>
  79. <value>true </value>
  80. <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>
  81. </property>

编辑(C:\hive\apache-hive-2.1.1-bin\conf\conf\hive-env.sh 文件)


  
  
  1. # Set HADOOP_HOME to point to a specific hadoop install directory
  2. export HADOOP_HOME= C:\hadoop\hadoop- 2.7. 6
  3. # Hive Configuration Directory can be controlled by:
  4. export HIVE_CONF_DIR= C:\hive\apache-hive- 2.1. 1-bin\conf
  5. # Folder containing extra libraries required for hive compilation/execution can be controlled by:
  6. export HIVE_AUX_JARS_PATH= C:\hive\apache-hive- 2.1. 1-bin\ lib

第六步:在hadoop上创建hdfs目录


  
  
  1. hadoop fs  -mkdir       /tmp
  2. hadoop fs  -mkdir       /user/
  3. hadoop fs  -mkdir       /user/hive/
  4. hadoop fs  -mkdir       /user/hive/warehouse 
  5. hadoop fs  -chmod g+w   /tmp
  6. hadoop fs  -chmod g+w   /user/hive/warehouse

第七步:创建Hive 初始化依赖的数据库hive,注意编码格式:latin1

第八步:启动Hive 服务

(1)、首先启动Hadoop,执行指令:stall-all.cmd

(2)、Hive 初始化数据,执行指令:hive --service metastore

             如果一切正常,cmd 窗口指令显示如下截图

          如果Hive 初始化正常,MySQL中Hive 数据库涉及表,如下截图:

          

(3)、启动Hive服务,执行指令:hive

至此,windows 10 搭建Hive 服务结束。

 

遇到的问题(1):Hive 执行数据初始化(hive --service metastore),总是报错。

解决思路:通过Hive 自身携带的脚本,完成Hive 数据库的初始化。

Hive 携带脚本的文件位置(C:\hive\apache-hive-2.1.1-bin\scripts\metastore\upgrade),选择执行SQL的版本,如下截图:

选择需要执行的Hive版本(Hive_x.x.x)所对应的sql 版本(hive-schema-x.x.x.mysql.sql)

说明:我选择Hive版本时2.1.1,所以我选项的对应sql 版本hive-schema-2..1.0.mysql.sql 脚本。

 

遇到的问题(2):Hive 的Hive_x.x.x_bin.tar.gz 版本在windows 环境中缺少 Hive的执行文件和运行程序。

解决版本:下载低版本Hive(apache-hive-1.0.0-src),将bin 目录替换目标对象(C:\hive\apache-hive-2.1.1-bin)原有的bin目录。

截图如下:apache-hive-1.0.0-src\bin 目录 结构

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值