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