Hive安装 保姆级安装教程

Hive安装 保姆级安装教程

1、内嵌模式

上传 压缩包  /opt/modules
解压:
tar -zxvf apache-hive-3.1.2-bin.tar.gz -C /opt/installs/
重命名:
mv apache-hive-3.1.2-bin/ hive
配置环境变量:vi /etc/profile
  export HIVE_HOME=/opt/installs/hive
  export PATH=$HIVE_HOME/bin:$PATH
刷新环境变量:
source /etc/profile
配置hive-env.sh
进入这个文件夹下:/opt/installs/hive/conf
cp hive-env.sh.template hive-env.sh
修改hive-env.sh 中的内容:
export HIVE_CONF_DIR=/opt/installs/hive/conf
export JAVA_HOME=/opt/installs/jdk
export HADOOP_HOME=/opt/installs/hadoop
export HIVE_AUX_JARS_PATH=/opt/installs/hive/lib

进入到conf 文件夹下,修改这个文件hive-site.xml
cp hive-default.xml.template hive-site.xml
接着开始修改:
把Hive-site.xml 中所有包含${system:java.io.tmpdir}替换成/opt/installs/hive/tmp。
如果系统默认没有指定系统用户名,那么要把配置${system:user.name}替换成当前用户名root。

在这里插入图片描述
启动集群:

start-dfs.sh
start-yarn.sh

给hdfs创建文件夹:

[root@bigdata01 conf] hdfs dfs -mkdir -p /user/hive/warehouse 
[root@bigdata01 conf] hdfs dfs -mkdir -p /tmp/hive/ 
[root@bigdata01 conf] hdfs dfs -chmod 750 /user/hive/warehouse 
[root@bigdata01 conf] hdfs dfs -chmod 777 /tmp/hive

初始化元数据,因为是内嵌模式,所以使用的数据库是derby

schematool --initSchema -dbType derby

在hive-site.xml中,3215行,96列的地方有一个非法字符
将这个非法字符,删除,保存即可。
在这里插入图片描述
需要再次进行元数据的初始化操作:

   schematool --initSchema -dbType derby

提示初始化成功!
初始化操作要在hive的家目录执行,执行完毕之后,会出现一个文件夹:

在这里插入图片描述
测试是否成功:

输入hive  进入后,可以编写sql
hive> show databases;
OK
default

3、测试内嵌模式

-- 进入后可以执行下面命令进行操作:
hive>show databases;          -- 查看数据库
hive>show tables;                   -- 查看表
-- 创建表
hive> create table dog(id int,name string);
hive> select * from dog;
hive> insert into dog values(1,'wangcai');
hive> desc dog; -- 查看表结构
hive> quit; -- 退出

2、本地模式–最常使用的模式

第一步:检查你的mysql是否正常

systemctl status mysqld

第二步:删除以前的derby数据

进入到hive中,删除 
rm -rf metastore_db/ derby.log

第三步:修改配置文件 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>

<
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值