【分布式数据仓库Hive】Hive的安装配置及测试

时间:2024-07-05 18:16:36

目录

一、数据库MySQL安装

1. 检查操作系统是否有MySQL安装残留

2. 删除残留的MySQL安装(使用yum)

3. 安装MySQL依赖包、客户端和服务器

4. MySQL登录账户root设置密码

5. 启动MySQL服务

6. 登录MySQL,进入数据库操作提示符

7. 授权Hive远程登录账户

8. 创建Hive元数据数据库hive_1

二、Hive安装配置(使用hadoop用户)

1. 上传压缩包apache-hive-3.1.2-bin.tar.gz到hadoop01(或者其他虚拟机)

2. 在安装目标文件夹内解压缩安装包

3. 编辑hive配置文件hive-site.xml

4. 解压并导入MySQL依赖包

5. 手动初始化元数据库(Hive2以上版本需要)

6. 配置hive启动的环境变量


引言

        本文有博主手敲代码,可以直接复制!(怕水印挡住截图大家看不清)文章也有贴上传到虚拟机所需的资源,是免费下载的!!如果对正在阅读博客的你有帮助,可以动动小手帮我点个赞或者收藏主页还有其他文章欢迎访问,你的关注将会是我更新的动力~谢谢!

一、数据库MySQL安装

使用root账户

1. 检查操作系统是否有MySQL安装残留

rpm -qa | grep -i mysql

 rpm -qa | grep -i mariadb

2. 删除残留的MySQL安装(使用yum)

yum -y remove mariadb*

3. 安装MySQL依赖包、客户端和服务器

在我上传的资源可以免费下载

https://download.****.net/download/m0_67830223/89512921?spm=1001.2014.3001.5503

rpm -ivh MySQL-server-community-5.1.73-1.rhel5.x86_64.rpm

 

rpm -ivh MySQL-client-community-5.1.73-1.rhel5.x86_64.rpm

 

rpm -ivh MySQL-devel-community-5.1.73-1.rhel5.x86_64.rpm

4. MySQL登录账户root设置密码

密码值自定义,这里设为‘abc1234
 

cd /usr/bin

mysqladmin -u root password 'abc1234'

5. 启动MySQL服务

systemctl start mysql.service  //启动mysql

systemctl status mysql.service //查看状态

6. 登录MySQL,进入数据库操作提示符

​​​​​​​mysql -u root -p

7. 授权Hive远程登录账户

grant all on *.* to 'ryx'@'%' identified by 'ryx123'; //“账户”和“密码”自定义

flush privileges; 

8. 创建Hive元数据数据库hive_1

可自命名,符合命名规则即可

create database hive_1;

二、Hive安装配置(使用hadoop用户

1. 上传压缩包apache-hive-3.1.2-bin.tar.gz到hadoop01(或者其他虚拟机)

在本文最上方资源可以免费下载!!

2. 在安装目标文件夹内解压缩安装包

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

3. 编辑hive配置文件hive-site.xml

(路径在hive安装目录的conf下)

cp hive-default.xml.template hive-site.xml

vi hive-site.xml

第1步,先删除hive-site.xml中的大部分内容,删除后的内容如下图所示:

第2步:在<configuration>标签对中添加以下内容

注意填写的value值根据自己的数据库名、账号密码修改!!!

<?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>hive.metastore.warehouse.dir</name>
        <value>/usr/hive/warehouse</value>
    </property>
    <property>
        <name>javax.jdo.option.ConnectionURL</name>
        <value>jdbc:mysql://192.168.9.10:3306/hive_1?characterEncoding=UTF-8</value>
        </description>
    </property>
    <property>
        <name>javax.jdo.option.ConnectionUserName</name>
        <value>ryx</value>
    <property>
        <name>javax.jdo.option.ConnectionDriverName</name>
        <value>com.mysql.jdbc.Driver</value>
    </property>
    <property>
        <name>javax.jdo.option.ConnectionPassword</name>
        <value>ryx123</value>
    </property>
</configuration>

4. 解压并导入MySQL依赖包

 在我上传的资源可以免费下载

https://download.****.net/download/m0_67830223/89512921?spm=1001.2014.3001.5503

tar -zxcf mysql-connector-java-5.1.27.tar.gz 

cd mysql-connector-java-5.1.27/  //进入解压的文件目录

sudo cp mysql-connector-java-5.1.27-bin.jar ~/apache-hive-3.1.0-bin/lib/ //将mysql的jar包复制到hive的lib目录下

5. 手动初始化元数据库(Hive2以上版本需要)

schematool -dbType mysql -initSchema

script completed

6. 配置hive启动的环境变量

export HIVE_HOME=/home/2130502441ryx/apache-hive-3.1.0-bin

export PATH=$HADOOP_HOME/sbin:$PATH:$HIVE_HOME/bin

7. 启动hive

​​​​​​​hive