HIVE安装详解

 

  • HIVE安装详解

  •  hive准备工作

系统环境是centos7

1、hadoop

2、mysql

这里我先不讲这两个的安装方式,之后在出帖子详解

简单说一下版本:

hadoop-2.6.5

mysql我是用的docker上的最新版本 docker pull mysql:latest 8.几的版本

后面hive会用到mysql-connector-java-8.0.19.jar包,这个包是和元数据存的mysql的版本相对应的,这个大家得注意

之后的帖子在去讲HBASE与hive关联吧

  •  hive

首先我们得对应hadoop的版本下载hive,我们的hadoop是2.x的所以,hive也要2.x的

下载地址:http://archive.apache.org/dist/hive/

大家下载对应的版本就行了

下载之后上传到自己的服务器

rz -E

放在指定目录解压即可

tar -zxvf apache-hive-2.1.1-bin.tar.gz

进入配置文件夹conf

cd /hadoop/apache-hive-2.1.1-bin/conf/
ls

这里面应该是没有hive-env.sh和hive-site.xml配置文件的

就需要cp hive-env.sh的模板并且创建hive-site.xml

 cp hive-env.sh.template hive-env.sh
touch hive-site.xml

打开hive-site.xml文件 vi hive-site.xml 添加以下内容,注意要自己修改成自己的mysql地址和用户哦

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
  Licensed 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. See accompanying LICENSE file.
-->

<!-- Put site-specific property overrides in this file. -->

<configuration>
        <property>
                <name>javax.jdo.option.ConnectionURL</name>
        <value>jdbc:mysql://192.168.200.11:3306/hive?createDatabaseIfNotExist=true</value>
        <description>Hive access metastore using JDBC connectionURL</description>
        </property>
        <property>
                <name>javax.jdo.option.ConnectionDriverName</name>
                <value>com.mysql.cj.jdbc.Driver</value>
        </property>
        <property>
                <name>javax.jdo.option.ConnectionUserName</name>
                <value>root</value>
        </property>
        <property>
                <name>javax.jdo.option.ConnectionPassword</name>
                <value>123456</value>
                <description>password to access metastore database</description>
        </property>
        <property>
                <name>hive.server2.transport.mode</name>
                <value>binary</value>
                <description>
                  Expects one of [binary, http].
                  Transport mode of HiveServer2.
                </description>
          </property>
</configuration>

然后在hive-env.sh文件下面追加hadoop地址

HADOOP_HOME=/hadoop/hadoop-2.6.5

然后在编辑一下环境变量/etc/profile文件

再把最开始说的mysql的mysql-connector-java-8.0.19.jar包放在lib下面

就可以初始化一下数据库了

schematool -dbType mysql -initSchema

之后试试

hive

然后在试试查看数据库命令

show databases;

安装成功

  •  开启远程访问

我们使用hive的时候并不是一直是在上面操作,更多的是远程操作hive,或者其他UI工具访问,比如hue,那么我们就要开始hive的远程访问了

首先得在hadoop的etc/hadoop/core-site.xml

<property>
    <name>hadoop.proxyuser.root.hosts</name>
    <value>*</value>
</property>
<property>
    <name>hadoop.proxyuser.root.groups</name>
    <value>*</value>
</property>

然后在hdfs-site.xml添加

<property>
  <name>dfs.webhdfs.enabled</name>
  <value>true</value>
</property>

然后就是启动呀,先启动hadoop

start-all.sh

在启动

hive --service metastore

然后切换用户su hive ,启动hiveserver2

hiveserver2

我们来测试一下

beeline
!connect jdbc:hive2://192.168.200.11:10000

也可以直接     -u : 指定元数据库的链接信息 -n : 指定用户名和密码

beeline -u jdbc:hive2://192.168.200.11:10000 -n root

 

  • 过程出现的错误

就是没有切换用户启动hiveserver2 切换了就对了

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值