伪分布Hadoop下安装Hive

一、下载并安装Mysql

(1)下载mysql安装包(mysql-8.0.26-1.el7.x86_64.rpm-bundle.tar)

        下载官网:MySQL :: Download MySQL Community Server (Archived Versions)icon-default.png?t=N7T8https://downloads.mysql.com/archives/community/

(2)上传mysql安装包并解压至/usr/local/

tar -xvf /opt/mysql-8.0.26-1.el7.x86_64.rpm-bundle.tar -C /usr/local

(3)进入/usr/local/,使用rpm安装mysql解压后的其中5个包(按照以下顺序安装)

rpm -ivh mysql-community-common-8.0.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.26-1.el7.x86_64.rpm 
rpm -ivh mysql-community-client-8.0.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.26-1.el7.x86_64.rpm

(4)启动/关闭Mysql服务器

#启动mysql服务
systemctl start mysqld
#查看mysql服务状态
systemctl status mysqld
#关闭mysql服务
systemctl stop mysqld
#重启mysql服务
service mysqld restart

二、查看Mysql的原始密码并登录进入mysql

(1)查看原始密码

[root@hadoop ~]# cat /var/log/mysqld.log | grep password
2024-04-20T16:41:01.790879Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 9m/O;xQbsfTk

 (2)使用原始密码登录

[root@hadoop ~]# mysql -uroot -p'9m/O;xQbsfTk'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.26

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

(3)修改密码为Admin@123456

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Admin@123456';
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
 
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Admin@123456';
Query OK, 0 rows affected (0.01 sec)

三、下载并安装Hive

Hive下载官网:Index of /dist/hive (apache.org)icon-default.png?t=N7T8https://archive.apache.org/dist/hive/

MySQL Connector下载地址:

MySQL :: Download MySQL Connector/J (Archived Versions)icon-default.png?t=N7T8https://downloads.mysql.com/archives/c-j/

(1)上传hive安装包到/opt目录,解压至/usr/local/

cd /opt
tar -zxvf apache-hive-3.1.2-bin.tar.gz -C /usr/local/

(2)添加环境变量

#打开系统环境变量配置文件
vim /etc/profile
#刷新一下配置文件
source /etc/profile

(3)解决日志Jar包冲突 

Hive由日志slf4j配置,但是我们yarn也有,两者会冲突。将hive安装目录下的lib目录的日志文件名修改。

cd /usr/local/apache-hive-3.1.2-bin/lib
mv log4j-slf4j-impl-2.10.0.jar log4j-slf4j-impl-2.10.0.jar.bak

四、将Hive元数据配置到MySQL

(1)将MySQL的JDBC驱动拷贝到Hive的lib目录下

MySQL Connector下载地址:

MySQL :: Download MySQL Connector/J (Archived Versions)icon-default.png?t=N7T8https://downloads.mysql.com/archives/c-j/

 (2)配置hive-site.xml

进入hive安装目录下的conf目录:cd /usr/local/apache-hive-3.1.2-bin/conf

在hive/conf目录下新建hive-site.xml文件:vim hive-site.xml 

<configuration>
   <property>
<!--Mysql的连接协议-->
        <name>javax.jdo.option.ConnectionURL</name>
        <value>jdbc:mysql://localhost:3306/metastore?useSSL=true</value>
    </property>
 
    <property>
        <name>javax.jdo.option.ConnectionDriverName</name>
        <value>com.mysql.jdbc.Driver</value>
    </property>
    <property>
<!--mysql  数据库账号-->
        <name>javax.jdo.option.ConnectionUserName</name>
        <value>root</value>
    </property>
 
    <property>
<!--mysql  数据库密码-->
        <name>javax.jdo.option.ConnectionPassword</name>
        <value>Admin@123456</value>
    </property>
 
    <property>
<!-- Hive 存储路径(hdfs路径)-->
        <name>hive.metastore.warehouse.dir</name>
        <value>/user/hive/warehouse</value>
    </property>
 
    <property>
<!-- Hive 元数据存储版本的验证 -->
        <name>hive.metastore.schema.verification</name>
        <value>false</value>
    </property>
 
    <property>
<!-- Hive jdbc连接端口:10000 -->
    <name>hive.server2.thrift.port</name>
    <value>10000</value>
    </property>
<!-- Hive 连接的主机 -->
    <property>
        <name>hive.server2.thrift.bind.host</name>
        <value>localhost</value>
    </property>
<!--元数据存储授权-->
    <property>
        <name>hive.metastore.event.db.notification.api.auth</name>
        <value>false</value>
    </property>
    <!-- 后两个是配置hive提示显示当前数据库名 -->
    <property>
        <name>hive.cli.print.header</name>
        <value>true</value>
    </property>
 
    <property>
        <name>hive.cli.print.current.db</name>
        <value>true</value>
    </property>
<!-- 将hive可以设置成本地模式来执行任务,不然会namenode内存空间不够,jvm不够新job启动导致。 -->
    <property>  
      <name>hive.exec.mode.local.auto</name>  
      <value>true</value>  
    </property>
</configuration>

五、启动Hive

        启动Hive之前,一定要先启动Hadoop集群。

(1)初始化客户端(进入mysql,新建Hive元数据库)

[root@hadoop conf]# mysql -uroot -p'Admin@123456'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.26 MySQL Community Server - GPL

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database metastore;
Query OK, 1 row affected (0.07 sec)

mysql> exit;
Bye
[root@hadoop conf]# 

(2)初始化Mysql服务器 

在启动Hive之前,需要执行schematool -dbType mysql initSchema

(3)启动hive

如果出现以下启动错误:

 解决方案:

查看该jar包在hadoop安装目录和hive的安装目录中的版本信息,将hadopp安装目录下的jar包替换hive安装目录下的jar包。

cd /usr/local/hadoop-3.1.4/share/hadoop/common/lib

cd /usr/local/apache-hive-3.1.2-bin/lib 

启动hive成功的界面(一定要先启动Hadoop集群):

相关推荐

  1. Hadoop 分布式安装

    2024-04-24 20:30:03       9 阅读
  2. Hadoop分布式集群安装

    2024-04-24 20:30:03       37 阅读
  3. 分布式部署Hive

    2024-04-24 20:30:03       21 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-04-24 20:30:03       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-04-24 20:30:03       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-04-24 20:30:03       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-04-24 20:30:03       18 阅读

热门阅读

  1. 关于文件上传的前后端优化

    2024-04-24 20:30:03       11 阅读
  2. go设计模式之工厂方法模式

    2024-04-24 20:30:03       10 阅读
  3. SQL server简介

    2024-04-24 20:30:03       11 阅读
  4. SQL Server详细使用教程

    2024-04-24 20:30:03       8 阅读
  5. class093 贪心经典题目专题5【左程云算法】

    2024-04-24 20:30:03       10 阅读
  6. 异步并发怎么做?

    2024-04-24 20:30:03       11 阅读
  7. 第三方包的info文件夹作用

    2024-04-24 20:30:03       7 阅读
  8. 服务运维篇-通过防火墙抵御渗透扫描

    2024-04-24 20:30:03       11 阅读
  9. K8s: 持久化存储之卷, NFS卷

    2024-04-24 20:30:03       10 阅读
  10. linux安装SSH

    2024-04-24 20:30:03       13 阅读
  11. 构建数据安全体系:详解数据治理的建设思路

    2024-04-24 20:30:03       11 阅读
  12. [Unity]打包Android后xxx方法丢失。

    2024-04-24 20:30:03       11 阅读
  13. IntelliJ IDEA个人可一直使用方法参考

    2024-04-24 20:30:03       11 阅读
  14. 任务修复实例(4)

    2024-04-24 20:30:03       10 阅读