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

  • Post author:
  • Post category:其他


一:下载

下载地址:

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端呢!!!



版权声明:本文为baidu_36336788原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。