Hive安装-windows(转载)

1.安装hadoopphp

2.从maven中下载mysql-connector-java-5.1.26-bin.jar(或其余jar版本)放在hive目录下的lib文件夹html

3.配置hive环境变量,HIVE_HOME=F:\hadoop\apache-hive-2.1.1-binjava

4.hive配置mysql

hive的配置文件放在$HIVE_HOME/conf下,里面有4个默认的配置文件模板sql

hive-default.xml.template                           默认模板数据库

hive-env.sh.template                hive-env.sh默认配置apache

hive-exec-log4j.properties.template    exec默认配置dom

 hive-log4j.properties.template               log默认配置maven

可不作任何修改hive也能运行,默认的配置元数据是存放在Derby数据库里面的,大多数人都不怎么熟悉,咱们得改用mysql来存储咱们的元数据,以及修改数据存放位置和日志存放位置等使得咱们必须配置本身的环境,下面介绍如何配置。分布式

(1)建立配置文件

$HIVE_HOME/conf/hive-default.xml.template  -> $HIVE_HOME/conf/hive-site.xml

$HIVE_HOME/conf/hive-env.sh.template  -> $HIVE_HOME/conf/hive-env.sh

$HIVE_HOME/conf/hive-exec-log4j.properties.template ->  $HIVE_HOME/conf/hive-exec-log4j.properties

$HIVE_HOME/conf/hive-log4j.properties.template  -> $HIVE_HOME/conf/hive-log4j.properties

(2)修改 hive-env.sh

export HADOOP_HOME=F:\hadoop\hadoop-2.7.2
export HIVE_CONF_DIR=F:\hadoop\apache-hive-2.1.1-bin\conf
export HIVE_AUX_JARS_PATH=F:\hadoop\apache-hive-2.1.1-bin\lib

(3)修改 hive-site.xml

  1  <!--修改的配置-->  
  2 
  3 <property>  
  4 
  5 <name>hive.metastore.warehouse.dir</name>  
  6 
  7 <!--hive的数据存储目录,指定的位置在hdfs上的目录-->  
  8 
  9 <value>/user/hive/warehouse</value>  
 10 
 11 <description>location of default database for the warehouse</description>  
 12 
 13 </property>  
 14 
 15 <property>  
 16 
 17 <name>hive.exec.scratchdir</name>  
 18 
 19 <!--hive的临时数据目录,指定的位置在hdfs上的目录-->  
 20 
 21 <value>/tmp/hive</value>  
 22 
 23 <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>  
 24 
 25 </property>  
 26 
 27 <property>  
 28 
 29 <name>hive.exec.local.scratchdir</name>  
 30 
 31 <!--本地目录-->  
 32 
 33 <value>F:/hadoop/apache-hive-2.1.1-bin/hive/iotmp</value>  
 34 
 35 <description>Local scratch space for Hive jobs</description>  
 36 
 37 </property>  
 38 
 39 <property>  
 40 
 41 <name>hive.downloaded.resources.dir</name>  
 42 
 43 <!--本地目录-->  
 44 
 45 <value>F:/hadoop/apache-hive-2.1.1-bin/hive/iotmp</value>  
 46 
 47 <description>Temporary local directory for added resources in the remote file system.</description>  
 48 
 49 </property>  
 50 
 51 <property>  
 52 
 53 <name>hive.querylog.location</name>  
 54 
 55 <!--本地目录-->  
 56 
 57 <value>F:/hadoop/apache-hive-2.1.1-bin/hive/iotmp</value>  
 58 
 59 <description>Location of Hive run time structured log file</description>  
 60 
 61 </property>  
 62 
 63 <property>  
 64 
 65 <name>hive.server2.logging.operation.log.location</name>  
 66 
 67 <value>F:/hadoop/apache-hive-2.1.1-bin/hive/iotmp/operation_logs</value>  
 68 
 69 <description>Top level directory where operation logs are stored if logging functionality is enabled</description>  
 70 
 71 </property>  
 72 
 73 <!--新增的配置-->  
 74 
 75 <property>  
 76 
 77 <name>javax.jdo.option.ConnectionURL</name>  
 78 
 79 <value>jdbc:mysql://localhost:3306/hive?characterEncoding=UTF-8</value>  
 80 
 81 </property>  
 82 
 83 <property>  
 84 
 85 <name>javax.jdo.option.ConnectionDriverName</name>  
 86 
 87 <value>com.mysql.jdbc.Driver</value>  
 88 
 89 </property>  
 90 
 91 <property>  
 92 
 93 <name>javax.jdo.option.ConnectionUserName</name>  
 94 
 95 <value>root</value>  
 96 
 97 </property>  
 98 
 99 <property>  
100 
101 <name>javax.jdo.option.ConnectionPassword</name>  
102 
103 <value>root</value>  
104 
105 </property>  
106 
107 <!-- 解决 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.autoCreateTables"  -->  
108 
109 <property>  
110 
111 <name>datanucleus.autoCreateSchema</name>  
112 
113 <value>true</value>  
114 
115 </property>  
116 
117 <property>  
118 
119 <name>datanucleus.autoCreateTables</name>  
120 
121 <value>true</value>  
122 
123 </property>  
124 
125 <property>  
126 
127 <name>datanucleus.autoCreateColumns</name>  
128 
129 <value>true</value>  
130 
131 </property>  
132 
133 <!-- 解决 Caused by: MetaException(message:Version information not found in metastore. )  -->  
134 
135 <property>    
136 
137 <name>hive.metastore.schema.verification</name>    
138 
139 <value>false</value>    
140 
141 <description>    
142 
143     Enforce metastore schema version consistency.    
144 
145     True: Verify that version information stored in metastore matches with one from Hive jars.  Also disable automatic    
146 
147           schema migration attempt. Users are required to manully migrate schema after Hive upgrade which ensures    
148 
149           proper metastore schema migration. (Default)    
150 
151     False: Warn if the version information stored in metastore doesn't match with one from in Hive jars.    
152 
153 </description>    
154 
155 </property>   

注:须要事先在hadoop上建立hdfs目录

 

(4)日志文件配置 略

 

5.MySQL设置

(1)建立hive数据库: create database hive default character set latin1;

(2)grant all on hive.* to hive@'localhost'  identified by 'hive'; 

 flush privileges;

--本人用的是root用户,因此这步省略

6.
(1)启动hadoop:start-all.cmd
(2)启动metastore服务:hive --service metastore
(3)启动Hive:hive
 若Hive成功启动,Hive本地模式安装完成。


七、查看mysql数据库
use hive; show tables;

8.在hive下建一张表:CREATE TABLE xp(id INT,name string) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'; 

9.在MySQL中查看:select * from TBLS

安装过程当中遇到的问题

 

(1)hive启动时报错Required table missing : "`VERSION`" in Catalog "" Schema "". DataNucleus requires this table to perform its persistence operations 参考 http://宋亚飞.中国/post/98 (2)Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient参考http://blog.csdn.net/freedomboy319/article/details/44828337(3)Caused by: MetaException(message:Version information not found in metastore. )参考 http://blog.csdn.net/youngqj/article/details/19987727(4)Hive 建立表报"Specified key was too long; max key length is 767 bytes" 错误参考 http://blog.csdn.net/niityzu/article/details/46606581其余参考文章:http://www.cnblogs.com/hbwxcw/p/5960551.html hive-1.2.1安装步骤http://blog.csdn.net/jdplus/article/details/46493553 Hive本地模式安装及遇到的问题和解决方案http://www.coin163.com/it/x8681464370981050716/spark-Hive CentOS7伪分布式下 hive安装过程当中遇到的问题及解决办法http://www.bogotobogo.com/Hadoop/BigData_hadoop_Hive_Install_On_Ubuntu_16_04.php APACHE HADOOP : HIVE 2.1.0 INSTALL ON UBUNTU 16.04

相关文章
相关标签/搜索