Hive系列 (一):Hive搭建

本文是Hive系列的第一篇,详细介绍了如何在阿里云ECS的CentOS8环境下搭建Hive,包括Hive的下载安装、mysql的下载配置、Hive的环境配置、启动服务以及beeline的配置。特别强调了Hive的远程模式安装,使用mysql存储元数据,并提供了遇到问题如JDK版本、guava依赖和mysql安装的注意事项。
摘要由CSDN通过智能技术生成

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
    
  2. 解压

    [hadoop@CentOS Downloads]$ tar -zxvf apache-hive-3.1.2-bin.tar.gz
    
  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
    

    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. 修改mysql配置文件

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

    在文件末尾添加

    [mysql]
    default-character-set=utf8
    [mysqld]
    character-set-server=utf8
    lower_case_table_names=1
    

    查找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
    
    
  2. 启动mysql服务

    [hadoop@CentOS ~]$ sudo service mysqld start
    Redirecting to /bin/systemctl start mysqld.service
    
  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.
    
  4. 启动

    [hadoop@CentOS ~]$ sudo service mysqld start
    Redirecting to /bin/systemctl start mysqld.service
    
  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> 
    
  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)
    
  7. 重启mysql服务

    [hadoop@CentOS ~]$ sudo service mysqld restart
    [sudo] password for hadoop: 
    Redirecting to /bin/systemctl restart mysqld.service
    
  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> 
    
  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%[==============================
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值