栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

02-Hive的安装

02-Hive的安装

Hive的安装 内嵌模式
使用hive自带默认元数据库derby来进行存储,通常用于测试
1.优点:使用简单,不用进行配置
2.缺点:只支持单session。

安装步骤(tianqinglong02)

[root@tianqinglong02 ~]# tar -zxvf apache-hive-2.1.1-bin.tar.gz -C /usr/local
[root@tianqinglong02 ~]# cd /usr/local
[root@tianqinglong02 local]# mv apache-hive-2.1.1-bin/ hive
[root@tianqinglong02 local]# vim /etc/profile
export HIVE_HOME=/usr/local/bin
export  PATH=$HIVE_HOME/bin:$PATH
:wq
[root@tianqinglong02 local]# source /etc/profile

配置hive-env.sh

如果不存在,就用hive.env.sh.template复制一个

[root@tianqinglong02 local]# cd hive/
[root@tianqinglong02 hive]# cd conf
[root@tianqinglong02 hive]# cp hive.env.sh.template hive-env.sh
[root@tianqinglong02 hive]# vim hive-env.sh
export JAVA_HOME=/usr/local/jdk
export HADOOP_HOME=/usr/local/hadoop
export HIVE_CONF_DIR=/usr/local/hive/conf
export HIVE_AUX_JARS_PATH=/usr/local/hive/lib
:wq

配置hive-site.xml

hive2.1.1中默认是没有hive-site.xml ,可以把conf /hive-default.xml .template拷贝过来使用

[root@tianqinglong02 conf]# cp hive-default.xml.template hive-site.xml
[root@tianqinglong02 conf]# vim hive-site.xml

把hive-site.xml中所有包含${system:java.io.tmpdir}替换成/usr/local/hive/iotmp.

:%s#${system:java.io.tmpdir}#/usr/local/hive/iotmp#g

如果系统默认没有指定系统用户名,那么要把配置${system:user.name}替换成当前用户名root
:%s/${system:user.name}/root#g
:wq

启动hadoop

[root@tianqinglong02 conf]# start-dfs.sh
[root@tianqinglong02 conf]# start-yarn.sh

初始化hive

[root@tianqinglong02 ~]# schematool --initSchema -dbType derby

启动hive

(注:启动之前要启动hdfs sbin/start-dfs.sh 和lyarn sbin/start-yarn.sh )

[root@tianqinglong02 ~]# hive

# 进入后可以执行下面命令进行操作:
hive> show databases; #查看数据库
hive> show tables;    #查看表
hive> quit            #退出

#不用内嵌模式
[root@tianqinglong02 ~]# rm -rf metastore_db/ derby.log
本地模式
使用mysql替换derby进行元数据的存储,hive的相关进程都是在同一台机器上,
即本地模式。mysql因为是独立的进程,所nmysql可以和hive在网一机器上,
也可以在其他机器上。

配置安装mysql

安装mysql服务器

[root@tianqinglong03 ~]# rpm -qa |grep mysql
[root@tianqinglong03 ~]# rpm -qa |grep mariadb
#如果有就删除 卸载的包是上方查询到的包
[root@tianqinglong03 ~]# rpm -e mariadb --nodeps
[root@tianqinglong03 ~]# tar -xvf mysql-5.7.28-1.el7.x86_64.rpm-bundle.tar
#安装MySQL,其实就需要安装mysql-community-server,但是它依赖其他的包
[root@tianqinglong03 ~]# rpm -ivh mysql-community-common-5.7.28-1.el7.x86_64.rpm
[root@tianqinglong03 ~]# rpm -ivh mysql-community-libs-5.7.28-1.el7.x86_64.rpm
[root@tianqinglong03 ~]# rpm -ivh mysql-community-client-5.7.28-1.el7.x86_64.rpm
[root@tianqinglong03 ~]# yum install -y net-tools
[root@tianqinglong03 ~]# yum install -y perl
[root@tianqinglong03 ~]# rpm -ivh mysql-community-server-5.7.28-1.el7.x86_64.rpm

[root@tianqinglong03 ~]# systemctl start mysqld
# 去获取初始密码
[root@tianqinglong03 ~]# grep passwd /var/log/mysqld.log
[root@tianqinglong03 ~]# mysql -u root -p
Enter password: 密码
# 改密码
#MySQL默认的密码安全等级有点高,在设置密码的时候,必须同时包含大小写字母、数字、特殊字符,以及对位数有要求
show variables like "%validate_password%" ;  #查看密码策略
set global validate_password_policy=LOW; #修改密码策略等级为LOW
set global validate_password_length=4;   #密码的最小长度
set global validate_password_mixed_case_count=0;#设置密码中至少要包含0个大写字母和小写字母
set global validate_password_number_count=0;#设置密码中至少要包含0个致字
set global validate_password_special_char_count=0;#设置密码中至少要包含0个特殊字符

#2.修改密码
mysql>alter user root@localhost identified by "123456';
#3. 远程授权
mysql> grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;

配置hive环境

1、解压并配置环境变量

2、配置hive的配置文件

cp hive-env.sh.template hive-env.sh
vi hive-env.sh(可以配置jdk、hive的conf路径)

3、在Hive的conf配置hive的自定义配置文件
vi hive-site.xml:添加如下内容

注意:前三步和内嵌模式一样

4.找到下面四个属性进行修改对应的值

[root@tianqinglong02 ~]# cd /usr/local/hive/conf/
[root@tianqinglong02 conf]# vim hive-site.xml


	javax.jdo.option.ConnectionURL
	jdbc:mysql://tianqinglong03:3306/hive?createDatabaseIfNotExist=true
    JDBC connect string for a JDBC metestore



	javax.jdo.option.ConnectionDriverName	
	com.mysql.jdbc.Driver
	Driver class name for a jDBC metastore



	javax.jdo.option.ConnectionUserName
	root
	username to use against metastore database



	javax.jdo.option.ConnectionPassword
	123456
	password to use against metastore database


5.将mysql驱动包mysql-connect-java-5.1.28-bin.jar上传到$HIVE_HOME/bin下

注意:驱动包是jar结尾不是tar

[root@tianqinglong01 ~]# scp mysql-connect-java-5.1.28-bin.jar tianqinglong02:/usr/local/hive/lib

6.初始化数据库

[root@tianqinglong02 lib]# schematool -initSchema -dbType mysql

7.启动hive

[root@tianqinglong02 lib]# hive
远程模式

使用远程模式,需要在hadoop的core-site.xml文件中添加以下属性 01 02 03


	hadoop.proxyuser.root.hosts
    *


    hadoop.proxyuser.root.groups
    *

[root@tianqinglong01 ~]# tar -zxvf apache-hive-2.1.1-bin.tar.gz -C /usr/local
[root@tianqinglong01 ~]# cd /usr/local
[root@tianqinglong01 local]# mv apache-hive-2.1.1-bin/ hive
[root@tianqinglong01 local]# vim /etc/profile
export HIVE_HOME=/usr/local/hive
export PATH=$PATH:$HIVE_HOME/bin
:wq
[root@tianqinglong01 local]# source /etc/profile
hive的两种服务说明

第一组服务 hiveserver2

[root@tianqinglong02 hadoop]# hive --service hiveserver2 &

[root@tianqinglong01 local]#  beeline
beeline> !connect jdbc:hive2://tianqinglong02:10000
root
123456
# 连接成功
0 : jdbc:hive2//tianqinglong02:1000> show databases;
0 : jdbc:hive2//tianqinglong02:1000> !quit

(直连)
[root@tianqinglong01 local]#  beeline -u jdbc:hive2://tianqinglong02:10000 -n root
# 连接成功
0 : jdbc:hive2//tianqinglong02:1000> show databases;
客户端连接metastore服务
[root@tianqinglong02 hadoop]# hive --service metastore

[root@tianqinglong01 local]# cd hive/conf
[root@tianqinglong01 conf]# cp hive-default.xml.template hive-site.xml

[root@tianqinglong01 conf]# vim hive-site.xml
# 19行往下都删

	hive.metastore.uris
	thrift://tianqinglong02:9083

:wq

[root@tianqinglong01 conf]#hive
hive> show databases;
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/460651.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号