Hive系列文章
Hive系列 (八):Hive中的explode 与 lateral view
一、环境信息
- 阿里云ECS—CentOS8
- jdk8(亲测,最高支持jdk8,再高版本启动hive服务会报错)
- hadoop 3.3.0
- hive-3.1.2
二、hive下载安装
-
下载hive,执行下面命令
[hadoop@CentOS Downloads]$wget https://apache.claz.org/hive/hive-3.1.2/apache-hive-3.1.2-bin.tar.gz -
解压
[hadoop@CentOS Downloads]$ tar -zxvf apache-hive-3.1.2-bin.tar.gz -
移动
[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.2Hive根据metastore的存储位置不同,分为三种安装模式:内嵌模式,本地模式,远程模式。内嵌模式就是使用derdy存储元数据;本地模式是将hvie.metastore.local设置为true,就是说metastore和hive客户端安装在同一台机器上;远程模式指的是我们明确指定metastore安装的机器位置,而且可以指定多个,需要给定参数hive.metastore.uris并且hive.metastore.local必须设置为false。
Hive远程模式安装,使用mysql进行元数据的存储。安装步骤:
(1) 安装mysql数据库。
(2) hive本地模式安装。
三、mysql下载安装及配置
-
下载安装mysql
[hadoop@CentOS ~]$ sudo yum install mysql [hadoop@CentOS ~]$ sudo yum install mysql-server


-
修改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 -
启动mysql服务
[hadoop@CentOS ~]$ sudo service mysqld start Redirecting to /bin/systemctl start mysqld.service -
设置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. -
启动
[hadoop@CentOS ~]$ sudo service mysqld start Redirecting to /bin/systemctl start mysqld.service -
登录
[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> -
创建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) -
重启mysql服务
[hadoop@CentOS ~]$ sudo service mysqld restart [sudo] password for hadoop: Redirecting to /bin/systemctl restart mysqld.service -
使用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> -
下载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%[==============================

本文是Hive系列的第一篇,详细介绍了如何在阿里云ECS的CentOS8环境下搭建Hive,包括Hive的下载安装、mysql的下载配置、Hive的环境配置、启动服务以及beeline的配置。特别强调了Hive的远程模式安装,使用mysql存储元数据,并提供了遇到问题如JDK版本、guava依赖和mysql安装的注意事项。
最低0.47元/天 解锁文章
811

被折叠的 条评论
为什么被折叠?



