hive安装——mysql作为元数据,使用beeline

hive安装——mysql作为元数据,使用beeline

本文主要介绍如何安装hive,同时hive用mysql作为数据源,最后会使用beeline的方式而不是hive CLI的方式进行hive操作。

好,下面上货。
1、下载hive,根据文档安装hive
官方文档

2、把hive的tar包tar开,然后放在指定目录下,这里我放在/usr/local下。
3、修改配置文件。
hive安装——mysql作为元数据,使用beeline_第1张图片

修改为如下内容:
hive安装——mysql作为元数据,使用beeline_第2张图片

4、修改hive-env.sh


5、修改系统环境变量。
HIVE_HOME=/usr/local/apache-hive-1.2.2-bin
export HIVE_HOME
export PATH=$HIVE_HOME/bin/:$PATH

6、添加hive-site.xml
  
    javax.jdo.option.ConnectionURL
    jdbc:mysql://192.168.1.120:3306/hive?useSSL=false
    JDBC connect string for a JDBC metastore
  
  
  
    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
  

7、 在lib下添加mysql的connector jar包

8、 由于hiveCLI已经被废弃了,所以 我们这里使用的是hive2 beeline的方式
$HIVE_HOME/bin/schematool -dbType mysql -initSchema

9、 运行结果:


运行出现错误:
hive安装——mysql作为元数据,使用beeline_第3张图片

10、重新安装mysql,可以参考如下文章 linux centos7 安装mysql。然后再次初始化 schematool -dbType mysql -initSchema。
hive安装——mysql作为元数据,使用beeline_第4张图片

11、使用beeline登录
首先需要后台启动hiveserver2
nohup hive --service hiveserver2
然后通过beeline命令进行登录
beeline -u jdbc:hive2://
或者beeline -u jdbc:hive2://cdh1:10000

12、运行结果如下:
hive安装——mysql作为元数据,使用beeline_第5张图片


你可能感兴趣的:(hive)