hive安装配置以及过程中的问题解决!!

1 篇文章 0 订阅
1 篇文章 0 订阅

一:下载
下载地址:http://mirror.bit.edu.cn/apache/hive/
下载到本地。我这里选择的版本是apache-hive-3.1.0-bin.tar.gz

二:使用第三方软件(我这里第三方软件是filezilla.exe)上传到/opt/目录下。。

三:配置环境变量

vim /etc/profile

将下面这段加入配置文件中:

export HIVE_HOME=/opt/apache-hive-3.1.0-bin
export PATH=$PATH:$HIVE_HOME/bin

并且执行:source /etc/profile 使其生效。。

四:验证是否安装成功

hive --version

有版本显示安装成功

五:配置

1.进入conf文件中,修改hive-site.xml

如果没有hive-site.xml 我们使用这个命令复制创建一个。(博主这里远原本也没这个文件,自己搭建完之后,才写的博客)
cp hive-default.xml.template hive-site.xml

vim hive-site.xml 

将下面配置信心放入hive-site.xml中,主要配置MySQL连接信息。

前提将复制mysql的驱动程序到apache-hive-3.1.0-bin/lib下面(注意下面的注意,很重要

<?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 -->

        <!-- 插入一下代码 -->
    <property>
        <name>javax.jdo.option.ConnectionUserName</name>用户名(这4是新添加的,记住删除配置文件原有的哦!)
        <value>root</value>
    </property>
    <property>
        <name>javax.jdo.option.ConnectionPassword</name>密码
        <value>123456</value>
    </property>
   <property>
        <name>javax.jdo.option.ConnectionURL</name>mysql
        <value>jdbc:mysql://192.168.1.38:3306/hive</value>
    </property>
    <property>
        <name>javax.jdo.option.ConnectionDriverName</name>mysql驱动程序
        <value>com.mysql.jdbc.Driver</value>
    </property>
        <!-- 到此结束代码 -->
  <property>
    <name>hive.exec.script.wrapper</name>
    <value/>
    <description/>
  </property>

执行以下命令hive进行初始化。
schematool -dbType mysql -initSchema

注意:起初我也是将上面代码,放入配置文件hive-site.xml中。但是接下来报了三个错。感觉有点坑。。
第一个错:比较简单,同时我也忘了截图。。抱歉    大概的错误意思是在3233行 ,&#8 无法识别,乱码。。我就果断删除这三个字符。

第二个错:下面有截图。网上查了一下。是xml的格式错误。打开hive-site.xml 发现最后一样  缺少 </configuration>。没有xml没有正确结束符。瞬间就想说nm,mmp,太坑了。。

第三个错:这个时候的错。我没有看见。而是我直接去数据命令  hive 去启动hive。结果报下面截图这个错。说是apache-hive-3.1.0-bin的文件下创建文件名为   iotmp    命令是:mkdir iotmp 

将hive-site.xml的${system:java.io.tmpdir}替换成" /opt/apache-hive-3.1.0-bin/iotmp/" 这个路径是我自己的,你替换成自己的路径就OK

补充:

启动hive
hive

并且创建hive数据库
create database hive_1;

发现报错。无法创建。不知道原因。在百度查,好多文章都说这个错,是在启动hive的时候报的错。结果,我无意之间发现了问题。。。再对hive初始化的时候,就已经报错了。。错误如下图。。

又查网站资料。。。决定删除hive-site.xml 内容
 

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
        <property>
                <name>javax.jdo.option.ConnectionURL</name>
                <value>jdbc:mysql://192.168.1.38:3306/my_link</value>
        </property>

        <property>
                <name>javax.jdo.option.ConnectionDriverName</name>
                <value>com.mysql.jdbc.Driver</value>
        </property>

        <property>
                <name>javax.jdo.option.ConnectionUserName</name>
                <value>root</value>
        </property>

        <property>
                <name>javax.jdo.option.ConnectionPassword</name>
                <value>Jd2016</value>
        </property>

        <property>
                <name>hive.metastore.schema.verification</name>
                <value>false</value>
        </property>
</configuration>

继续验证以上修改的错误:

输入命令:schematool -dbType mysql -initSchema

初始化成功。

启动hive数据库

重新创建hive数据库

六:hive测试

hdfs存了什么

hadoop fs -lsr /

那么我们去看看MySQL      
select * from DBS;

在my_hive创建一个hive_01表

先切换到my_hive库中。。

use my_hive;

再去创建表

create table hive_01 (id int,name string,age int);

再去查看hdfs

在MySQL下

select * from TBLS;

那么web端呢!!!

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值