赞
踩
操作系统centOS 6.5
Hadoop版本:hadoop 2.7.6
JDK版本:JDK 1.8.0
mysql版本:mysql 5.7
一、安装准备
1. 从官网下载解压hive的bin压缩文件 , 此处使用的是hive-2.1.1版本
2. 通过ftp传输到linux系统,使用tar -xzvf apache-hive-2.1.1-bin.tar.gz解压缩。
二、嵌入式模式的安装配置
1. 进入hive解压缩后的文件bin目录,执行./hive会自动创建derby数据库保存元信息。并进入hive命令行模式
2. 执行quit;命令退出,发现bin目录下多了保存元数据的文件。说明嵌入式模式已完成安装。
3. HIVE_HOME的配置:修改配置文件/etc/profile加入HIVE_HOME到系统path;执行source /etc/profile使配置立即生效。
export HIVE_HOME=/usr/local/hive
export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$HIVE_HOME/bin
三、远程模式
1. 在windows上也解压hive的源安装文件。
2. 在mysql官网下载mysql-connector-java-5.1.46.tar.gzwen在文件,解压缩后,将其中的mysql-connector-java-8.0.12.jar文件上传到Linux系统中的/hive/lib/目录下。
3. 相关文件配置
(1)hive-env.sh
- export JAVA_HOME=/usr/local/jdk1.8.0
- export HADOOP_HOME=/usr/local/hadoop-2.7.6
- export HIVE_HOME=/usr/local/hive-2.1.1
- export HIVE_CONF_DIR=${HIVE_HOME}/conf
- export HIVE_AUX_JARS_PATH=${HIVE_HOME}/lib
(2) hive-log4j2.properties
执行cp hive-log4j2.properties.template hive-log4j2.properties
修改hive-log4j2.properties中的以下配置
- property.hive.log.level = INFO
- property.hive.root.logger = DRFA
- property.hive.log.dir = /user/hive/log
- property.hive.log.file = hive.log
- property.hive.perflogger.log.level = INFO
(3) hive-site.xml
在/hive/conf目录下创建hive-site.xml文件,配置以下信息.
其中***.***.***.***是本地windows主机的ip,3306是mysql默认的port.
- <?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <?xml-stylesheet type="text/xsl" href="configuration.xsl"?><!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- --><configuration>
- <!-- WARNING!!! This file is auto generated for documentation purposes ONLY! -->
- <!-- WARNING!!! Any changes you make to this file will be ignored by Hive. -->
- <!-- WARNING!!! You must make your changes in hive-site.xml instead. -->
- <!-- Hive Execution Parameters -->
- <!-- 设置 hive仓库的HDFS上的位置 -->
- <property>
- <name>hive.exec.scratchdir</name>
- <value>/user/hive/tmp</value>
- </property>
- <!--资源临时文件存放位置 -->
- <property>
- <name>hive.metastore.warehouse.dir</name>
- <value>/user/hive/warehouse</value>
- </property>
- <!-- 设置日志位置 -->
- <property>
- <name>hive.querylog.location</name>
- <value>/user/hive/log</value>
- </property>
- <property>
- <name>javax.jdo.option.ConnectionURL</name>
- <value>jdbc:mysql://192.168.***.***:3306/hive? createDatabaseIfNotExist=true&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true</value>
- </property>
- <property>
- <name>javax.jdo.option.ConnectionDriverName</name>
- <value>com.mysql.jdbc.Driver</value>
- </property>
- <property>
- <name>javax.jdo.option.ConnectionUserName</name>
- <value>hive</value>
- </property>
- <property>
- <name>javax.jdo.option.ConnectionPassword</name>
- <value>zzwzyt</value>
- </property>
- <property>
- <name>hive.metastore.schema.verification</name>
- <value>false</value>
- </property>
- <property>
- <name>hive.exec.reducers.bytes.per.reducer</name>
- <value>256000000</value>
- <description>size per reducer.The default is 256Mb, i.e if the input size is 1G, it will use 4 reducers.</description>
- </property>
- <property>
- <name>hive.exec.reducers.max</name>
- <value>999</value>
- <description>
- max number of reducers will be used. If the one specified in the configuration parameter mapred.reduce.tasks is
- negative, Hive will use this one as the max number of reducers when automatically determine number of reducers.
- </description>
- </property>
- </configuration>
4. 复制 mysql-connector-java-5.1.46.jar 到hive的lib文件夹下
5. 设置hive账户支持远程登录
进入mysql命令行,执行update user set host='%' where user='hive';
再执行flush privileges; 使修改生效。
6. 在linux上执行hive命令,再quit;退出。发现mysql的hive数据库下多了很多保存元信息的表,说明远程模式安装配置成功。
6. 在hive命令行创建一个测试表格create test3,即可在mysql中查到相关元信息。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。