hadoop-2.6.0下hive-1.2.2安装与配置

Posted owen-li

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了hadoop-2.6.0下hive-1.2.2安装与配置相关的知识,希望对你有一定的参考价值。

1集群组成

集群建设与centos7上
ServerNameHadoop ClusterZookeeperHBase Cluster
server1Name node & Resource manager,secondary name node
yesmaster
server2Data node & Node manager
yesRegion server
server3Data node & Node manager
yesRegion server
server4Data node & Node manager
yesRegion server

hive只需要在server1上安装配置。

2:下载解压hive-1.2.2

下载地址: 将tar包移动到/usr/local/hadoop-2.6.0此为hadoop的安装目录。(可随意放置)
cd /usr/local/hadoop-2.6.0
tar -zxvfapache-hive-1.2.2-bin.tar.gz
mv  apache-hive-1.2.2-bin.tar.gz hive-1.2.2

3:设置环境变量:

HIVE_HOME=/usr/local/hadoop-2.6.0/hive-1.2.2
PATH=$HIVE_HOME/bin:$PATH
CLASSPATH=$CLASSPATH:$HIVE_HOME/lib
export HIVE_HOME
export PATH
export CLASSPATH
执行:source /etc/profile

4:安装配置数据库(mariadb)

yum install mariadb mariadb-server
systemctl enable mariadb
systemctl start mariadb

4.1:下载mysql驱动

mariadb装好后去网上下载一个链接MYSQLJDBC驱动,对应自己的数据库版本下载相应的jdbc,mysql-connector-java-5.5.38-bin.jar此处下载的是:将jdbc放入到hive的解压文件的lib目录下。

驱动下载

4.2:创建和授权mysql用户

mysql_secure_installation ——>设置root用户密码
mysql -u root -p ——>输入root用户密码,进入数据库.
create database hiveDB;——>创建数据库
create user "hive"@'%' identified by "redhat";   ——>创建一个名为hive密码为redhat的用户,其可以从任意地方登陆
grant all privileges on hiveDB.* to hive@'%'; ——>授予hive用户对hiveDB的所有权限
flush privileges; ——>刷新系统权限

5:配置hive,配置文件在hive的conf目录下面

5.1:配置hive-site.xml

配置hive-site.xmlconf目录下应该没有这个文件,需要将hive-default.xml.template中的配置文件中内容复制到hive-site.xml文件中,但是现在我们只需要用一些配置信息,所以可以在conf目录下直接新建hive-site.xml,然后在文件中写入一下内容即可。

<?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>
<property>
        <name>hive.exec.scratchdir</name>
        <value>hdfs://server1:9000/tmp/hive</value>
</property>
<property>
        <name>javax.jdo.option.ConnectionURL</name>
        <value>jdbc:mysql://server1:3306/hiveDB?createDatabaseIfNotExist=true&characterEncoding=UTF-8</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>redhat</value>
</property>
<property>
        <name>hive.metastore.warehouse.dir</name>
      <value>hdfs://server1:9000/hive/warehouse</value>
        <description>location of default database for the warehouse</description>
</property>
<property>
        <name>javax.jdo.option.Multithreaded</name>
        <value>true</value>
</property>
</configuration>

注:hive.exec.scratchdir是执行HIVE操作访问HDFS用于临时存储数据的目录
javax.jdo.option.ConnectionURL ->
设置hive通过JDBC链接MYSQL数据库存储metastore存放的数据库地址 
javax.jdo.option.ConnectionDriverName ->
设置链接mysql的驱动名称。 
javax.jdo.option.ConnectionUserName ->
设置存储metastore内容的数据库用户名 
javax.jdo.option.ConnectionPassword ->
设置存储metastore内容的数据库用户名密码 
hive.metastore.warehouse.dir ->
设置用于存放hive元数据的目录位置,改配置有三种模式,内嵌模式,本地元数据,远程元数据。

5.2:配置hive-env.sh

cp hive-env.sh.template hive-env.sh
vim hive-env.sh
HADOOP_HOME=/usr/local/hadoop-2.6.0
# Hive Configuration Directory can be controlled by:
export HIVE_CONF_DIR=/usr/local/hadoop-2.6.0/hive-1.2.2/conf
注:次 时也不能启动 hive 服务,因为 Hadoop 的版本是 2.6.0 hive 的版本是 1.2.2 HIVE_HOME/lib 目录下的 jline-2.12.jar HADOOP_HOME/share/hadoop/yarn/lib 下的 jline-0.9.94.jar 版本高,版本不一致导致。所以将 HIVE_HOME/lib 目录下的 jline-2.12.jar 复制到 HADOOP_HOME/share/hadoop/yarn/lib 下,并将 jline-0.9.94.jar 删除,然后重启 hadoop

 cp /usr/local/hadoop-2.6.0/hive-1.2.2/bin/lib/jline-2.12.jar /usr/local/hadoop-2.6.0/share/hadoop/yarn/lib/
rm  /usr/local/hadoop-2.6.0/share/hadoop/yarn/lib/jline-0.9.94.jar

6:完成验证:

当在命令行输入hive无报错,出现交互界面,及成功安装。




以上是关于hadoop-2.6.0下hive-1.2.2安装与配置的主要内容,如果未能解决你的问题,请参考以下文章

hadoop window下安装 hadoop-2.6.0

hadoop包安装

Centos6下安装Hadoop2.6 问题总结

hadoop2.6集群下Zookeeper与Hbase的安装与配置

hadoop安装时报错 /usr/local/hadoop-2.6.0-stable/hadoop-2.6.0-src/hadoop-hdfs-project/hadoop-hdfs/target/f

Eclipse安装Hadoop插件配置Hadoop开发环境