hadoop集群安装hive

最近在学习Spark,在Ubuntu中安装完Hadoop之后,安装hive出现了些问题,找了很多的资料,最终成功安装。现在将查找到资料里的安装步骤整理如下。
1:下载hive安装包,可以在通过http://mirror.bit.edu.cn/apache/hive/hive-2.3.5/进行下载,得到文件apache-hive-2.3.5-bin.tar.gz;
2:解压

tar -zxvf  apache-hive-2.3.5-bin.tar.gz -C /usr/local/;(其中/usr/local/为安装路径,可以自行选择);

3:更改环境变量:sudo vim ~/.bashrc,然后再文件头部添加
export HIVE_HOME=/usr/local/hive
export PATH=$PATH:$HIVE_HOME/bin
同时确保Hadoop路径也在该文件中,如下图:
路径设置
修改完路径后运行语句:

source ~/.bashrc

4:检测hive 版本:
hive --version,
在这里插入图片描述
5:穿件分布式文件,用于存储Hive的表格和数据(确保已经启动hadoop):

hdfs dfs -mkdir -p /user/hive/warehouse
hdfs dfs -mkdir -p /user/hive/warehouse

6:设置读/写的权限:

hdfs dfs -chmod g+w /user/hive/warehouse
hdfs dfs -chmod g+w /tmp

7:在hive-env.sh中添加hadoop路径

cd /usr/local/hive/
cp conf/hive-env.sh.template conf/hive-env.sh
sudo vim conf/hive-env.sh
进行如下修改:

在这里插入图片描述

8:编辑hive-site.xml文件:
sudo vim 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>javax.jdo.option.ConnectionURL</name>
<value>jdbc:derby:;databaseName=/usr/local/hive/metastore_db;create=true</value>#此处与hive路径对应
<description>
JDBC connect string for a JDBC metastore.
To use SSL to encrypt/authenticate the connection, provide database-specific SSL flag in the connection URL.
For example, jdbc:postgresql://myhost/db?ssl=true for postgres database.
</description>
</property>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
<description>location of default database for the warehouse</description>
</property>
<property>
<name>hive.metastore.uris</name>
<value/>
<description>Thrift URI for the remote metastore. Used by metastore client to connect to remote metastore.</description>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>org.apache.derby.jdbc.EmbeddedDriver</value>
<description>Driver class name for a JDBC metastore</description>
</property>
<property>
<name>javax.jdo.PersistenceManagerFactoryClass</name>
<value>org.datanucleus.api.jdo.JDOPersistenceManagerFactory</value>
<description>class implementing the jdo persistence</description>
</property>
</configuration>

9:Hive 默认使用Derby database,初始化Derby database

/usr/local/hive/bin/schematool -initSchema -dbType derby
结果如下图
![在这里插入图片描述](https://img-blog.csdnimg.cn/2019062417333643.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTM5MDQwMzI=,size_16,color_FFFFFF,t_70)

10 运行hive
在这里插入图片描述
11:运行测试:

show databases;
create table employee (id string, name string, dept string) row format delimited fields terminated by ‘	‘ stored as textfile;
show tables;

在这里插入图片描述
12 退出:

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值