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

hive 安装教程

hive 安装教程

hive 安装教程 hive几种交互式使用方式

1、hive交互shell bin/hive

2、hive jdbc服务(参考java jdbc链接mysql)

3、hive 启动为一个服务,来对外提供服务

控制台启动:bin/hiveserver2

命令行启动:nohub /bin/hiveserver2 1>/var/log/hiveserver2.log 2> /var/log/hiveserver.err &

启动成功后使用 可以在别的节点使用beeline去链接

/bin/beeline -u jdbc:hive2://youduk3:10000 -n root

或者使用命令行

bin/beeline

! connect jdbc:hive2://youduk3:10000

4、hive 命令

hive -e sql

/bin/hive -e ‘select * from t_test’

安装教程

1、安装包下载

hive 下载地址

https://dlcdn.apache.org/hive/

apache-hive-1.2.2-bin.tar.gz

下载安装包

mkdir -p /home/bigdata/

安装包放入到 /home/bigdata/中

tar -zxvf apache-hive-1.2.2-bin.tar.gz

cd apache-hive-1.2.2-bin


2、配置环境变量

export HIVE_HOME=/home/bigdata/apache-hive-1.2.2-bin

export PATH=.: H I V E H O M E / b i n : HIVE_HOME/bin: HIVEH​OME/bin:PATH

保存退出

source /etc/profile 立即生效

启动方式 1、derby启动方式

bin/hive
退出

会增加两个文件
derby日志文件和 数据库文件。

derby 方式 元数据无法共享。用来做测试实验

2、mysql启动方式

mysql 安装方式,请参考 https://mp.csdn.net/mp_blog/creation/editor/122499748

配置hive环境变量

vim conf/hive-env.sh 配置其中的$hadoop_home

cp conf/hive-env.sh.template conf/hive-env.sh
hive默认配置 conf/hive-default.xml.template

自定义配置

vi conf/hive-site.xml


    
        javax.jdo.option.ConnectionDriverName
        com.mysql.cj.jdbc.Driver
        Driver class name for a JDBC metastore
    
    
        javax.jdo.option.ConnectionURL
        jdbc:mysql://youduk5:3306/hive?allowPublicKeyRetrieval=true&createDatabaseIfNotExist=true
        JDBC connect strin
    
    
        javax.jdo.option.ConnectionUserName
        root
        Username to use against metastore database
    
    
        javax.jdo.option.ConnectionPassword
        xxxxxx
        password to use against metastore database
    

自定义配置可以在conf/hive-default.xml.template 找到

&createDatabaseIfNotExist=true 如果没有 自动创建。

hive 需要手动配置mysql链接驱动

下载mysql驱动放到 lib下

启动

bin/hive

Logging initialized using configuration in jar:file:/home/bigdata/apache-hive-1.2.2-bin/lib/hive-common-1.2.2.jar!/hive-log4j.properties
hive>
hive> create database h_it
hive> show databases;
OK
default
h_it
退出控制台

再次进入 bin/hive

Logging initialized using configuration in jar:file:/home/bigdata/apache-hive-1.2.2-bin/lib/hive-common-1.2.2.jar!/hive-log4j.properties
hive> show databases;
OK
default
h_it

mysql 方式安装成功。

验证:
http://youduk3:50070/
目录可以配置

hive-site.xml中配置


  hive.metastore.warehouse.dir
  /user/hive/warehouse

MySQL中同样可以看到:

show databases;

use hive;

show tables;

select * from TBLS;

select * from COLUMNS_V2;

3、hive集群搭建

1、 mysql 中已经存在的mysql 删掉 。或换一个数据库名称
2、准备3台虚拟机
​ youduk3、youduk4、youduk5 mysql 安装 youduk5




 
    javax.jdo.option.ConnectionURL
    jdbc:mysql://youduk5:3306/hive?allowPublicKeyRetrieval=true&createDatabaseIfNotExist=true
    JDBC connect string for a JDBC metastore


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


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


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



    hive.exec.local.scratchdir
    /home/bigdata/apache-hive-1.2.2-bin/iotmp
    Local scratch space for Hive jobs


    hive.downloaded.resources.dir
    /home/bigdata/apache-hive-1.2.2-bin/iotmp
    Temporary local directory for added resources in the remote file system.


4、配置mysql驱动

下载mysql驱动放到 lib下

5、到 bin目录下执行初始化

​ schematool -dbType mysql -initSchema ## MySQL作为元数据库,此时在hive的bin目录

6、使用scp打包hive到子节点

scp -r /home/bigdata/apache-hive-1.2.2-bin root@youduk4:/home/bigdata/
scp -r /home/bigdata/apache-hive-1.2.2-bin root@youduk5:/home/bigdata/

7、配置子节点的环境变量

上面介绍了。参照安装教程中配置环境变量章节

8、配置hive-config.sh文件

cd /home/bigdata/apache-hive-1.2.2-bin

vi hive-config.sh ################添加如下内容

export JAVA_HOME=/opt/jdk1.8.0_181

export HADOOP_HOME=/opt/hadoop-2.7.7

9、启动hive

1)启动metastore服务

​ 先启动hadoop start-all.sh # 启动metastore服务,执行Hive前, 须先启动metastore服务, 否则会报错 ./hive --service metastore # 此时在hive的bin目录

2)启动hive

3) 配置从节点配置

vim conf/hive-site.xml

  
    hive.metastore.uris  
    thrift://youduk3:9083
    Thrift URI for the remote metastore. Used by metastore client to connect to remote metastore.  

从节点 bin/hive

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/711062.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

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

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