惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Hackread – Cybersecurity News, Data Breaches, AI and More
宝玉的分享
宝玉的分享
月光博客
月光博客
爱范儿
爱范儿
阮一峰的网络日志
阮一峰的网络日志
酷 壳 – CoolShell
酷 壳 – CoolShell
Recent Announcements
Recent Announcements
A
About on SuperTechFans
T
The Blog of Author Tim Ferriss
博客园 - 叶小钗
U
Unit 42
aimingoo的专栏
aimingoo的专栏
Y
Y Combinator Blog
Martin Fowler
Martin Fowler
N
Netflix TechBlog - Medium
博客园 - 司徒正美
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
云风的 BLOG
云风的 BLOG
M
MIT News - Artificial intelligence
大猫的无限游戏
大猫的无限游戏
J
Java Code Geeks
V
Visual Studio Blog
腾讯CDC
IT之家
IT之家

中文博客 on 范叶亮 | Leo Van

多智能体系统 (Multi-Agent System) 确定性和掌控欲 - 你的 AI 不是你的 AI LLM Token 消耗节省计划 (How to Save Token for LLM) 智能体的角色定位和身份演化 (Agent Role Orientation and Identity Evolution) 本地部署 OpenClaw,QwenPaw 和 Hermes Agent (Local Deployment of OpenClaw, QwenPaw and Hermes Agent) 本地部署智能体 - OpenClaw,QwenPaw,Hermes Agent ... 部署 Matrix 服务器 Synapse (Deployment of Matrix Server Synapse) 部署 frp 内网穿透服务 (Deployment of frp NAT Traversal Service) 本地部署大模型服务 (Local Deployment of LLM Services) AI 时代的生产力和生产关系 (Forces and Relations of Production in AI Era) 业余无线电入门 - CQ, CQ, CQ, this is BD1CZP. Calling CQ and standing by. 重构 - 之于代码、之于工作、之于生活 大语言模型微调 (Fine-tuning Large Language Models) 提升图片分辨率和质量 - Invoke AI 101 教程 使用画布创建和组合生成新的图片 - Invoke AI 101 教程 探索 AI 模型和概念适配器 - Invoke AI 101 教程 理解图像到图像和降噪过程 - Invoke AI 101 教程 使用控制层和指示控制图片的生成 - Invoke AI 101 教程 使用 Invoke 创作你的第一张图片 - Invoke AI 101 教程 在 OpenWrt 和群晖中自动申请和部署证书 凡人歌 - 凡人,但不要烦心 Shell 调用方式 fork,exec 和 source (Run Shell with fork, exec and source) 重定向和管道 (Redirect and Pipe) 模型压缩和推理加速 (Model Compression and Inference Acceleration) 我们需要多少种编程语言 (How Many Programming Languages do We Need) 数据可视化小贴士 - 面向动态文档生成,秉承规范、统一和实用的理念 从 rm -rf * 说起 - 喜新、怀旧、再出发 当我谈摄影时,我谈些什么 - 色彩篇 Part 1 CSS 布局和定位 (CSS Layout and Position) 当我谈修图时,我谈些什么 - 色彩篇 Part 1
Hive 安装和配置 (Hive Setup)
范叶亮 · 2021-06-14 · via 中文博客 on 范叶亮 | Leo Van

Hive 安装和配置

Hive Setup

分类: Tech101, 教程 / 字数: 1016 / 标签: Hive, MySQL, MySQL JDBC Connector


文本使用的软件版本分别为:

  1. JDK:1.8.0_291,下载地址
  2. Hadoop:3.2.2,下载地址
  3. Hive:3.2.1,下载地址
  4. MySQL:8.0.25,使用 apt install mysql-server 安装。
  5. MySQL JDBC Connector:8.0.25,下载地址

按照虚拟环境准备 (Virtual Environment Preparation) 准备虚拟机列表如下:

主机名 IP 角色
vm-01 192.168.56.101 Hadoop
MySQL
Hive
vm-02 192.168.56.102 Hadoop
vm-03 192.168.56.103 Hadoop

按照 Hadoop 集群搭建 (Hadoop Cluster Setup) 搭建 Hadoop 集群。

MySQL 安装和配置

通过如下命令安装 MySQL:

sudo apt install mysql-server mysql-client libmysqlclient-dev

安装完毕后,使用如下命令初始化 MySQL:

sudo mysql_secure_installation

在密码安全性校验步骤,输入 N 关闭密码安全性校验:

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No: N

输入新密码:

New password: *********
Re-enter new password: *********

在删除匿名用户环节,输入 Y 删除匿名用户:

By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y

输入 N 允许远程登录 root 用户:

Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : N

输入 N 保留 test 数据库:

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : N

输入 Y 应用设置并生效:

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y

修改 MySQL 配置文件:

sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf

将绑定地址替换为 0.0.0.0

bind-address            = 0.0.0.0
mysqlx-bind-address     = 0.0.0.0

重启 MySQL 服务:

sudo service mysql restart

在本地通过如下命令并输入密码进入 MySQL:

在 MySQL 命令行中输入如下语句为 root 用户配置允许远程访问:

CREATE USER 'root'@'%' IDENTIFIED BY '**********';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;

之后在宿主机通过如下命令即可登录虚拟机中的 MySQL:

mysql -h192.168.56.101 -uroot -p

为 Hive 创建数据库和用户,并设置相关权限:

CREATE DATABASE hive;
CREATE USER 'hive'@'%' IDENTIFIED BY '**********';
GRANT ALL PRIVILEGES ON hive.* TO 'hive'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;

将 Hive 安装包解压缩到 /opt 目录并创建软链接:

cd /opt
tar -zxvf apache-hive-3.1.2-bin.tar.gz
ln -s /opt/apache-hive-3.1.2-bin /opt/hive

将如下信息添加到 /etc/profile 中:

## Hive
export HIVE_HOME=/opt/hive
export PATH=$PATH:$HIVE_HOME/bin

复制环境变量文件:

cp /opt/hive/conf/hive-env.sh.template /opt/hive/conf/hive-env.sh

修改 hive-env.sh 内容如下:

export JAVA_HOME=/opt/jdk
export HADOOP_HOME=/opt/hadoop
export HIVE_HOME=/opt/hive
export HIVE_CONF_DIR=$HIVE_HOME/conf

创建配置文件:

vi /opt/hive/conf/hive-site.xml

修改 hive-site.xml 内容如下:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
  <property>
    <name>javax.jdo.option.ConnectionURL</name>
    <value>jdbc:mysql://vm-01:3306/hive</value>
  </property>
  <property>
    <name>javax.jdo.option.ConnectionDriverName</name>
    <value>com.mysql.cj.jdbc.Driver</value>
  </property>
  <property>
    <name>javax.jdo.option.ConnectionUserName</name>
    <value>hive</value>
  </property>
  <property>
    <name>javax.jdo.option.ConnectionPassword</name>
    <value>*********</value>
  </property>
</configuration>

将 MySQL JDBC Connector 解压缩到 /opt/hive/lib 中:

cd /opt
tar -zxvf mysql-connector-java-8.0.25.tar.gz
mv /opt/mysql-connector-java-8.0.25/mysql-connector-java-8.0.25.jar /opt/hive/lib
rm -rf /opt/mysql-connector-java-8.0.25

修正不兼容的依赖包:

mv /opt/hive/lib/log4j-slf4j-impl-2.10.0.jar /opt/hive/lib/log4j-slf4j-impl-2.10.0.jar.bak
mv /opt/hive/lib/guava-19.0.jar /opt/hive/lib/guava-19.0.jar.bak
cp /opt/hadoop/share/hadoop/common/lib/guava-*.jar /opt/hive/lib

初始化元数据:

schematool -dbType mysql -initSchema

出现如下输出时表示元数据初始化成功:

Metastore connection URL:	 jdbc:mysql://vm-01:3306/hive
Metastore Connection Driver :	 com.mysql.cj.jdbc.Driver
Metastore connection User:	 hive
Starting metastore schema initialization to 3.1.0
Initialization script hive-schema-3.1.0.mysql.sql
......
Initialization script completed
schemaTool completed

启动 Hive

执行如下命令启动 Hive:

出现如下输出时表示启动成功:

Hive Session ID = f3edb53b-5037-47c3-b318-75854e2328c5

Logging initialized using configuration in jar:file:/opt/apache-hive-3.1.2-bin/lib/hive-common-3.1.2.jar!/hive-log4j2.properties Async: true
Hive Session ID = 3331472a-a171-47be-843a-378611233f18
Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.
hive>