当前位置:   article > 正文

Hive系列 (一):Hive搭建

hive搭建

Hive系列文章

Hadoop完全分布式搭建(腾讯云服务器+阿里云服务器)

Hive系列 (一):Hive搭建

Hive系列 (二):Hive基础知识

Hive系列 (三):开窗函数详解

Hive系列 (四):自定义函数UDF UDTF UDAF

Hive系列 (五):Hive数据类型

Hive系列 (六):Hive数据类型转换

Hive系列 (七):Hive常用函数

Hive系列 (八):Hive中的explode 与 lateral view

Hive系列 (九):Hive数据存储

Hive系列 (十):Hive调优

一、环境信息

  1. 阿里云ECS—CentOS8
  2. jdk8(亲测,最高支持jdk8,再高版本启动hive服务会报错)
  3. hadoop 3.3.0
  4. hive-3.1.2

二、hive下载安装

  1. 下载hive,执行下面命令

    [hadoop@CentOS Downloads]$wget https://apache.claz.org/hive/hive-3.1.2/apache-hive-3.1.2-bin.tar.gz
    
    • 1
  2. 解压

    [hadoop@CentOS Downloads]$ tar -zxvf apache-hive-3.1.2-bin.tar.gz
    
    • 1
  3. 移动

    [hadoop@CentOS Downloads]$ mv apache-hive-3.1.2-bin/ ../hive-3.1.2/
    [hadoop@CentOS hive-3.1.2]$ pwd
    /home/hadoop/hive-3.1.2
    
    • 1
    • 2
    • 3

    Hive根据metastore的存储位置不同,分为三种安装模式:内嵌模式,本地模式,远程模式。内嵌模式就是使用derdy存储元数据;本地模式是将hvie.metastore.local设置为true,就是说metastore和hive客户端安装在同一台机器上;远程模式指的是我们明确指定metastore安装的机器位置,而且可以指定多个,需要给定参数hive.metastore.uris并且hive.metastore.local必须设置为false。
    Hive远程模式安装,使用mysql进行元数据的存储。安装步骤:
    (1) 安装mysql数据库。
    (2) hive本地模式安装。

三、mysql下载安装及配置

  1. 下载安装mysql

    [hadoop@CentOS ~]$ sudo yum install mysql
    [hadoop@CentOS ~]$ sudo yum install mysql-server
    
    • 1
    • 2

在这里插入图片描述
在这里插入图片描述

  1. 修改mysql配置文件

    [hadoop@CentOS ~]$sudo vim /etc/my.cnf
    
    • 1

    在文件末尾添加

    [mysql]
    default-character-set=utf8
    [mysqld]
    character-set-server=utf8
    lower_case_table_names=1
    
    • 1
    • 2
    • 3
    • 4
    • 5

    查找yum安装软件位置:

    #查找安装包
    [hadoop@CentOS ~]$ rpm -qa|grep mysql
    mysql-errmsg-8.0.21-1.module_el8.2.0+493+63b41e36.x86_64
    mysql-common-8.0.21-1.module_el8.2.0+493+63b41e36.x86_64
    mysql-8.0.21-1.module_el8.2.0+493+63b41e36.x86_64
    mysql-server-8.0.21-1.module_el8.2.0+493+63b41e36.x86_64
    
    #查找安装包的安装位置
    [hadoop@CentOS ~]$ rpm -ql mysql-server-8.0.21-1.module_el8.2.0+493+63b41e36.x86_64
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
  2. 启动mysql服务

    [hadoop@CentOS ~]$ sudo service mysqld start
    Redirecting to /bin/systemctl start mysqld.service
    
    • 1
    • 2
  3. 设置root密码

    [hadoop@CentOS ~]$ mysqladmin -u root password 123456
    mysqladmin: [Warning] Using a password on the command line interface can be insecure.
    Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
    
    • 1
    • 2
    • 3
  4. 启动

    [hadoop@CentOS ~]$ sudo service mysqld start
    Redirecting to /bin/systemctl start mysqld.service
    
    • 1
    • 2
  5. 登录

    [hadoop@CentOS ~]$ mysql -u root -p
    Enter password: 
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 12
    Server version: 8.0.21 Source distribution
    
    Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
    
    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> 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
  6. 创建hive用户并授权

    mysql> create user 'hive' identified by 'hive';
    Query OK, 0 rows affected (0.01 sec)
    
    mysql> grant all privileges on *.* to 'hive'@'%' with grant option;
    Query OK, 0 rows affected (0.01 sec)
    
    • 1
    • 2
    • 3
    • 4
    • 5
  7. 重启mysql服务

    [hadoop@CentOS ~]$ sudo service mysqld restart
    [sudo] password for hadoop: 
    Redirecting to /bin/systemctl restart mysqld.service
    
    • 1
    • 2
    • 3
  8. 使用hive用户登录测试连接

    [hadoop@CentOS ~]$ mysql -u hive -p
    Enter password: 
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 8
    Server version: 8.0.21 Source distribution
    
    Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
    
    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> 
    mysql> create database hive;
    Query OK, 1 row affected (0.00 sec)
    
    mysql> alter database hive character set latin1;
    Query OK, 1 row affected (0.01 sec)
    mysql> 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
  9. 下载mysql jar包,将jar包放入hive lib目录下

    [hadoop@CentOS Downloads]$ wget https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.21/mysql-connector-java-8.0.21.jar
    --2021-06-16 16:48:39--  https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.21/mysql-connector-java-8.0.21.jar
    Resolving repo1.maven.org (repo1.maven.org)... 151.101.196.209
    Connecting to repo1.maven.org (repo1.maven.org)|151.101.196.209|:443... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 2397321 (2.3M) [application/java-archive]
    Saving to: ‘mysql-connector-java-8.0.21.jar’
    
    mysql-connector-java-8.0 100%[==============================
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Guff_9hys/article/detail/919343
推荐阅读
相关标签
  

闽ICP备14008679号