大数据实操篇 No.5-Hive 高可用方式集群部署

第1章 简介

Hive是一个工具,原理是mapreduce,可以让用户以sql的方式去做数据分析汇总。

第2章 安装

2.1 解压

$ tar -zxvf apache-hive-1.2.1-bin.tar.gz -C /opt/module/

2.2 修改conf目录下配置

$ mv hive-env.sh.template hive-env.sh
$ vi hive-env.sh

2.3 配置HADOOP_HOME路径

export HADOOP_HOME=/opt/module/hadoop-3.1.2

根据自己机器上的hadoop安装目录,自行配置。 

2.4 配置HIVE_CONF_DIR路径

export HIVE_CONF_DIR=/opt/module/hive/conf

第3章 安装配置Mysql

3.1 安装Mysql

生产环境hive的元数据推荐配置到mysql中,所以mysql必须安装。这里略。

3.2 配置Hive元数据到Mysql

解压mysql驱动,驱动下载链接:mysql-jdbc-connector-java-5.1.44.zip

$ unzip mysql-connector-java-5.1.44.zip -d /opt/module/apache-hive-3.1.2-bin/lib/

拷贝mysql驱动jar包到hive的lib目录下

$ cp ./mysql-connect-java-5.1.27-bin.jar /opt/module/hive/lib/

Hive中conf目录下新建hive-site.xml文件

$ touch hive-site.xml

添加配置信息,内容参考hive-default.template





 javax.jdo.option.ConnectionURL
 jdbc:mysql://webapp200:3306/metastore?createDatabaseIfNotExist=true
 
      JDBC connect string for a JDBC metastore.
      To use SSL to encrypt/authenticate the connection, provide database-specific SSL flag in the connection URL.
      For example, jdbc:postgresql://myhost/db?ssl=true for postgres database.
 



 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
 password
 password to use against metastore database

 

 hive.metastore.warehouse.dir
 /user/hive/warehouse
 location of default database for the warehouse



    hive.metastore.schema.verification
    true

hive.metastore.warehouse.dir注意权限

$ bin/hdfs dfs -chmod g+w /user/hive/warehouse

第4章 修改hive默认日志路径

conf目录下修改hive-log4j.properties

$ mv hive-log4j.properties.template hive-log4j.properties
$ vi hive-log4j.properties

修改内容

property.hive.log.dir = /opt/module/apache-hive-3.1.2-bin/logs

第5章 高可用HA

注:hiveservermetastore进程名都叫RunJar

5.1 Metastore高可用

将hive文件分发到各集群节点

Metastore服务多节点启动,hive-site.xml配置按3.2配置即可。

在你的Hive client节点hive-site.xml中添加如下配置。


    hive.metastore.uris
   thrift://hadoop100:9083,thrift://hadoop101:9083

5.2 HiveServer2高可用

笔者这里还未用到HiveServer2,所以这里略过。

第6章 启动

6.1 启动hdfs和yarn

hive是执行mapreduce任务,计算hdfs上存储的数据,所以必须先启动hdfs和yarn

6.2 启动hive metastore服务

$ bin/hive --service metastore &

后台启动

$ nohup bin/hive --service metastore 2>&1 >> /opt/module/apache-hive-3.1.2-bin/logs/metastore.log &

运行进程:

7370 RunJar

6.3 启动hive client命令

$ bin/hive

到此,Hive已经安装配置好了,进入hive client后就可以执行SQL语句进行数据计算分析了,生产环境一般通过定时任务去执行Hive SQL脚本,笔者会在后续文章中进行介绍。

 

 

 

你可能感兴趣的:(从0到1的大数据探索,hive,hadoop,大数据,sql,hdfs)