CentOS7 Hive2.3.8 安装图文教程

一、 安装MySQL

0.0)查询mariadb,有就去0.1),没有就不管直接去1)
bash 复制代码
rpm -qa | grep mariadb
0.1)卸载mariadb
bash 复制代码
rpm -e --nodeps 查询出来的内容

二、安装MySQL

1.下载资源包 官网下载

MySQL官网下载地址:https://dev.mysql.com/downloads/mysql/

2.解压

注:本文安装包上传到/tools解压到了 /usr/local/ 目录下

进入安装包目录

复制代码
cd /tools

拆分tar包

复制代码
tar -xvf mysql-8.0.30-el7-x86_64.tar -C /usr/local/

解压安装包

复制代码
cd /usr/local/

tar -zxvf mysql-8.0.30-el7-x86_64.tar.gz

将解压后的文件夹重命名为mysql

复制代码
mv mysql-8.0.30-el7-x86_64/ mysql

创建存储数据文件

在重命名后的mysql文件夹中创建data文件夹

复制代码
mkdir mysql/data

设置用户组并赋权

创建用户组

复制代码
groupadd mysql

创建用户

-r:创建系统用户

-g:指定用户组

复制代码
useradd -r -g mysql mysql

更改属主和数组

复制代码
chown -R mysql:mysql /usr/local/mysql/

更改权限

复制代码
chmod -R 755 /usr/local/mysql/

初始化MySQL

进入MySQL的bin目录

复制代码
cd /usr/local/mysql/bin/

初始化

复制代码
./mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql

这里会打印临时密码,一会登录用得到自己注意

3.配置参数文件
复制代码
vi /etc/my.cnf

配置文件修改为以下内容,也可以根据自己需要设置参数。

复制代码
[client]
port = 3306
socket = /usr/local/mysql/data/mysql.sock
default-character-set = utf8mb4

[mysql]  
default-character-set = utf8mb4

[mysqld]  
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_general_ci
init_connect = 'SET NAMES utf8mb4'

port = 3306
socket = /usr/local/mysql/data/mysql.sock
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
datadir = /usr/local/mysql/data
#lower_case_table_names=1
#如果要设置lower_case_table_names可以在初始化里面设置 ./mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql --lower_case_table_names=1

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash

[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout

配置后修改 /etc/my.cnf 的权限为777

复制代码
chmod 777 /etc/my.cnf

启动MySQL

复制代码
/usr/local/mysql/support-files/mysql.server start

设置软连接,并重启MySQL

复制代码
ln -s /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
ln -s /usr/local/mysql/mysql.sock /var/mysql.sock
service mysql restart

登录并更改密码

复制代码
mysql -u root -p

Enter password: 输入初始化随机密码

两种改密方式二选一

复制代码
alter user 'root'@'localhost' identified by '123456';
set password for root@localhost = '123456';

开放远程连接

复制代码
mysql>use mysql;
msyql>update user set user.Host='%' where user.User='root';
mysql>flush privileges;    //刷新权限

安装Hive

a. 创建一个test数据库测试一下是否正常:

bash 复制代码
create database test;

b. 使用数据库mysql:

bash 复制代码
use mysql;

c. 输入命令看配置

bash 复制代码
select host, user, authentication_string, plugin from user;

我们需要一个 hiveuser 对应 % 的用户,所以加一个

bash 复制代码
CREATE USER 'hiveuser'@'%' IDENTIFIED BY '123456';

加好了,查看一下,就有% hiveuser 的用户了

bash 复制代码
select host, user, authentication_string, plugin from user;

要是太长了串行了可以省略点查看

bash 复制代码
select host, user from user;

f. 给hiveuser授权一下

bash 复制代码
GRANT ALL ON *.* TO 'hiveuser'@'%';

g. 手动更新配置:

bash 复制代码
 flush privileges;

二、安装 Hive:

1)把apache-hive-2.3.8-bin.tar.gz 下载后 用mobaxterm放到 /tools文件夹

链接:https://pan.baidu.com/s/1NBplQ4GYGfsa25aSK7I8OQ?pwd=vzji

提取码:vzji

--来自百度网盘超级会员V6的分享

2)解压文件
bash 复制代码
tar -zvxf /tools/apache-hive-2.3.8-bin.tar.gz -C /training/
3)进入 /training 文件夹
bash 复制代码
cd /training

重命名移动文件夹为hive

bash 复制代码
mv apache-hive-2.3.8-bin hive
4) 设置环境变量
bash 复制代码
vi ~/.bash_profile	

加进去

bash 复制代码
export HIVE_HOME=/training/hive
export PATH=$PATH:$HIVE_HOME/bin

:wq 保存退出后,更新环境变量文件

bash 复制代码
source ~/.bash_profile
5) Hive配置文件更改

进入配置文件夹

bash 复制代码
cd /training/hive/conf

复制备份hive-env.sh.template并命名为hive-env.sh

bash 复制代码
cp hive-env.sh.template hive-env.sh 

复制备份hive-default.xml.template并命名为hive-site.xml

bash 复制代码
cp hive-default.xml.template hive-site.xml
6) 配置 hive-site.xml,这个文件内容特别多,所以一次性删光了再往里面加东西

进入文件

bash 复制代码
vi hive-site.xml

直接键盘敲6000dd,此命令意思是删除6000行,不要复制

bash 复制代码
6000 dd	

如果还没删空,就多来几次6000dd

删空后加入以下内容,注意复制进去的时候不要少了>符号之类的小错误,此文件涉及到之前设置的密码123456,如果你不一样,记得改

bash 复制代码
#Enter the insert mode by pressingi and then copy this code to the file and save and exit using- :wq.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<!-- WARNING!!! This file is auto generated for documentation purposes ONLY! -->
<!-- WARNING!!! Any changes you make to this file will be ignored by Hive.   -->
<!-- WARNING!!! You must make your changes in hive-site.xml instead.         -->
<!-- Hive Execution Parameters -->
<property>
<name>hive.default.fileformat</name>
<value>TextFile</value>
</property>
<property>
<!--The port is changed to your own port. Here is the onhive database in the connection database. If not, create it later -->
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost/metastore</value>
<description>JDBC connect string for a JDBC metastore</description>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<!--The latest version of the jar package to connect to MySQL All write com.mysql.cj.jdbc.Driver, if it is the old version with com.mysql.jdbc.Driver-->
<value>com.mysql.cj.jdbc.Driver</value>
<description>Driver class name for a JDBC metastore</description>
</property>
<property>
<!--Connect to MySQL username-->
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
<description>username to use against metastore database</description>
</property>
<property>
<!--Connect MySQL password -->
<name>javax.jdo.option.ConnectionPassword</name>
<value>123456</value>
<description>password to use against metastore database</description>
</property>
</configuration>
7)配置 hive-env.sh

进入文件

bash 复制代码
vi hive-env.sh

在文件最底下加,注意hadoop版本和java版本以及路径是否和我一样,不一样记得换

bash 复制代码
export HADOOP_HOME=/training/hadoop-3.3.0
export HIVE_CONF_DIR=/training/hive/conf
export HIVE_AUX_JARS_PATH=/training/hive/lib
export JAVA_HOME=/training/jdk1.8.0_144
export HIVE_HOME=/training/hive
8)把 MySQL的 connected jar文件放到 hive/lib 文件夹下

链接:https://pan.baidu.com/s/1gD2M8Gr9IFOkOA4EghfWLg?pwd=32r8

提取码:32r8

--来自百度网盘超级会员V6的分享

9)进入 /training/hadoop-3.3.0/share/hadoop/hdfs/lib/

找到这个瓜娃27,把它下载到桌面上留着

10)进入 /training/hive/lib

把瓜娃27放进去,并且删除这个瓜娃14

11)启动Hadoop
bash 复制代码
start-all.sh
12) 复制一个窗口进入这个路径
bash 复制代码
cd /training/hive/scripts/metastore/upgrade/mysql/

输入命令后输密码123456 进入mysql

bash 复制代码
mysql -u root --p

输命令创建数据库metastore用于存储元数据

bash 复制代码
create database metastore;
12) 回到Linux代码页面初始化mysql
bash 复制代码
schematool -dbType mysql -initSchema

成功的话会有这个提示

Starting metastore schema initialization to 2.3.8 Initialization

script hive-schema-2.3.8.mysql.sql Initialization script completed

schemaTool completed

13)进入hive测试;

进hive命令行

bash 复制代码
hive

创建库

bash 复制代码
create database hive1;

显示库,可以看到hive1

bash 复制代码
show databases;

退出

bash 复制代码
exit;
14)用hdfs看看刚刚的hive1
bash 复制代码
hdfs dfs -ls /user/hive/warehouse

关掉hadoop

bash 复制代码
stop-all.sh
相关推荐
悟乙己2 小时前
PySpark 与 Pandas 的较量:Databricks 中 SQL Server 到 Snowflake 的数据迁移之旅
数据库·pandas·pyspark
云手机掌柜3 小时前
下一代社媒运营工具:亚矩阵云手机集成AIGC与数字人技术引领内容革命
大数据·线性代数·智能手机·矩阵·aigc
上海锝秉工控4 小时前
超声波风向传感器:以科技之翼,捕捉风的每一次呼吸
大数据·人工智能·科技
Menior_5 小时前
【MySQL】基本查询
数据库·mysql
在未来等你6 小时前
Elasticsearch面试精讲 Day 13:索引生命周期管理ILM
大数据·分布式·elasticsearch·搜索引擎·面试
一只游鱼6 小时前
Redis入门(部署、持久化、缓存问题)
数据库·redis·缓存
北城以北88887 小时前
数据库--MySQL数据管理
数据库·mysql
代码的余温7 小时前
Oracle RAC共享存储核心技术
数据库·oracle