从hbase中拿数据,然后整合到hbase中

上hive官网  -- 点击wiki--> hive hbase integation(整合) --》 注意整合的时候两个软件的版本要能进行整合 按照官网的要求

在整合之前需要将hive 的jar进行导入 : hive-hbase-handler-x.y.z.jar   
单节点的启动命令
$HIVE_SRC/build/dist/bin/hive --auxpath
$HIVE_SRC/build/dist/lib/hive-hbase-handler-0.9.0.jar,
$HIVE_SRC/build/dist/lib/hbase-0.92.0.jar,
$HIVE_SRC/build/dist/lib/zookeeper-3.3.4.jar,$HIVE_SRC/build/dist/lib/guava-r09.jar
--hiveconf hbase.master=hbase.yoyodyne.com:60000
集群的启动命令 --至少三个集群  
$HIVE_SRC/build/dist/bin/hive --auxpath $HIVE_SRC/build/dist/lib/hive-hbase-handler-0.9.0.jar,$HIVE_SRC/build/dist/lib/hbase-0.92.0.jar,$HIVE_SRC/build/dist/lib/zookeeper-3.3.4.jar,$HIVE_SRC/build/dist/lib/guava-r09.jar --hiveconf hbase.zookeeper.quorum=zk1.yoyodyne.com,zk2.yoyodyne.com,zk3.yoyodyne.com

--需要将hive和hbase的jar进行整合  
a)先将hbase中的jar包拷贝到hive中  
cp ./*.jar /root/apache-hive-1.2.1-bin/lib/
b)将hive的jar包拷贝到hbase 中
cp ./hive-hbase-hadler.jar   
c)在hive客户端分别启动habse 和 hive  启动 没有先后顺序  
  启动hbase   start-hbase.sh   
  启动hive   现在服务端启动hive服务   hive --service metastore
  然后在客户端启动hive  ./hive  
  在客户端启动hbase   hbase shell  
  将hbase的列映射到hive中
 3、在hive中创建临时表

CREATE EXTERNAL TABLE tmp_order
(key string, id string, user_id string)  
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'  
WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,order:order_id,order:user_id")  
TBLPROPERTIES ("hbase.table.name" = "t_order");

CREATE TABLE hbasetbl(key int, value string)
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf1:val")
TBLPROPERTIES ("hbase.table.name" = "xyz", "hbase.mapred.output.outputtable" = "xyz");

在hive中插入数据,数据最终会被插入到hbase中
要创建hive外部表,需要先在hbase中创建这个表,然后在hive中创建这个表

sqoop相关知识总结  
sqoop由client端直接接入hadoop,任务通过解析生成对应的mapreduce执行
安装步骤:
1、解压
2、配置环境变量
export SQOOP_HOME= /XX/sqoop.xx
3、添加数据库驱动包
cp mysql-connector-java-5.1.10.jar/sqoop-install-path/lib
4、 重命名配置文件
 mv sqoop-env-template.sh sqoop-env.sh
sqoop list-databases --connect jdbc:mysql://node1:3306 -username root --password 123

sqoop import --connect  jdbc:mysql://node1:3306/test  --username root --password 123 --columns  start_ip,end_ip,country --delete-target-dir -m 1 -table test2 --target-dir /sqoop/
 
也可以将sqoop命令放到一个文件中 再进行执行
将sqoop放置到文件中的格式
import
--connect
jdbc:mysql://node1:3306/test  
--username
root
--password
123
--columns  
start_ip,end_ip,country
--delete-target-dir
-m
1
-table
test2
--target-dir
/sqoop/

执行文件的命令: sqoop --options-file option

2、在文件中加入具体的sql执行语句
import
--connect
jdbc:mysql://node1:3306/test  
--username
root
--password
123
--delete-target-dir
-m
1
--target-dir
/sqoop/
-e select start_ip,end_ip from test2 where $CONDITIONS

执行文件的命令:sqoop --options-file option1
注: sql语句后面必须包含条件 $CONDITIONS

在hive中查询执行的结果:

dfs-cat /sqoop/*

在hive文件条件查询中添加配置条件  
import
--connect
jdbc:mysql://node1:3306/test  
--username
root
--password
123
--columns  
start_ip,end_ip,country
--delete-target-dir
-m
1
-table
test2
--target-dir
/sqoop/
--where
"country = 'US'"

---将mysql的数据直接导入到hive表中
import
--connect
jdbc:mysql://node1:3306/test  
--username
root
--password
123
--columns  
start_ip,end_ip,country
--delete-target-dir
-m
1
-table
test2
--hive-import
--create-hive-table
--hive-table
sqoophive

注意命令文件的书写格式

---将hive的数据导出到mysql
export
--connect
jdbc:mysql://node1:3306/test  
--username
root
--password
123
--columns  
start_ip,end_ip,country
-m
1
--table
h_sql
--export-dir
/sqoop/

注:要将hive的数据导入到mysql中,hive文件中存储的数据必须是具有mysql能够接受的数据格式,才能够将数据全部的导入。

from (
 
     select
    pl, from_unixtime
    (cast(s_time/1000 as bigint),'yyyy-MM-dd') as day, u_ud,
   
      (case when count(p_url) = 1 then "pv1"
      
     when count(p_url) = 2 then "pv2"
     
      when count(p_url) = 3 then "pv3"
      
        when count(p_url) = 4 then "pv4"
      
       when count(p_url) >= 5 and count(p_url) <10 then "pv5_10"
     
       when count(p_url) >= 10 and count(p_url) <30 then "pv10_30"
      
       when count(p_url) >=30 and count(p_url) <60 then "pv30_60"  
     
       else 'pv60_plus' end) as pv
 
       from event_logs
 
      where
    en='e_pv'
    
      and p_url is not null
    
      and pl is not null
    
      and s_time >= unix_timestamp('2019-03-15','yyyy-MM-dd')*1000
    
      and s_time < unix_timestamp('2019-03-15,'yyyy-MM-dd')*1000
 
       group by
    pl, from_unixtime(cast(s_time/1000 as bigint),'yyyy-MM-dd'), u_ud

) as tmp

insert overwrite table stats_view_depth_tmp
 
      select pl,day,pv,count(distinct u_ud) as ct where u_ud is not null group by pl,day,pv;

hbase-hive整合及sqoop的安装配置使用的更多相关文章

  1. Sqoop的安装配置及使用

    一.Sqoop基础:连接关系型数据库与Hadoop的桥梁 1.1 Sqoop的基本概念 Hadoop正成为企业用于大数据分析的最热门选择,但想将你的数据移植过去并不容易.Apache Sqoop正在加 ...

  2. 【sqoop】安装配置测试sqoop1

    3.1.1 下载sqoop1:sqoop-1.4.7.bin__hadoop-2.6.0.tar.gz 3.1.2 解压并查看目录: [hadoop@hadoop01 ~]$ tar -zxvf sq ...

  3. 一脸懵逼学习Hive的元数据库Mysql方式安装配置

    1:要想学习Hive必须将Hadoop启动起来,因为Hive本身没有自己的数据管理功能,全是依赖外部系统,包括分析也是依赖MapReduce: 2:七个节点跑HA集群模式的: 第一步:必须先将Zook ...

  4. 1 复习ha相关 + weekend110的hive的元数据库mysql方式安装配置(完全正确配法)(CentOS版本)(包含卸载系统自带的MySQL)

    本博文的主要内容是: .复习HA相关 .MySQL数据库 .先在MySQL数据库中建立hive数据库 .hive的配置 以下是Apache Hadoop HA的总结.分为hdfs HA和yarn HA ...

  5. Java Web整合开发(附录1) - 安装配置环境

    1. Install JDK http://blog.csdn.net/sonnet123/article/details/9169741 Download JDK http://www.oracle ...

  6. 大数据之路week07--day06 (Sqoop 的安装及配置)

    Sqoop 的安装配置比较简单. 提供安装需要的安装包和连接mysql的驱动的百度云链接: 链接:https://pan.baidu.com/s/1pdFj0u2lZVFasgoSyhz-yQ 提取码 ...

  7. hbase 2.0.2 分布式安装配置/jar包替换

    环境 zk: 3.4.10 hadoop 2.7.7 jdk8 hbase 2.0.2 三台已安装配置好的hadoop002,hadoop003,hadoop004 1.上传并解压hbase-2.1. ...

  8. Hive 系列(一)安装部署

    Hive 系列(一)安装部署 Hive 官网:http://hive.apache.org.参考手册 一.环境准备 JDK 1.8 :从 Oracle 官网下载,设置环境变量(JAVA_HOME.PA ...

  9. cdh版本的hue安装配置部署以及集成hadoop hbase hive mysql等权威指南

    hue下载地址:https://github.com/cloudera/hue hue学习文档地址:http://archive.cloudera.com/cdh5/cdh/5/hue-3.7.0-c ...

随机推荐

  1. Optaplanner规划引擎的工作原理及简单示例(2)

    开篇 在前面一篇关于规划引擎Optapalnner的文章里(Optaplanner规划引擎的工作原理及简单示例(1)),老农介绍了应用Optaplanner过程中需要掌握的一些基本概念,这些概念有且于 ...

  2. JavaScript 集合对象

    1. 集合对象 1.1 Object 关于Object类型的创建和底层存储原理我在另一篇文章有说明: JavaScript 对象属性底层原理 我们知道了大多数情况下Object底层都是Hash结构,我 ...

  3. SX_WIN10X64LTSB2016_EN_LITE英文精简版

    SX_WIN10X64LTSB2016_EN_LITE英文精简版该版本为英文版!该版本为英文版!该版本为英文版!因为论坛巴基斯坦的maanu兄弟PM我,所以抽空做了一个.介绍沿用原来的,中文用谷歌翻译 ...

  4. 在ubuntu下装python3.6

    Ubuntu 14.04 and 16.04 If you are using Ubuntu 14.04 or 16.04, you can use J Fernyhough's PPA at htt ...

  5. listview-android:打造万能通用适配器(转)

    转载:https://blog.csdn.net/q649381130/article/details/51781921: 1.前言 listview作为安卓项目中一个的明星控件,它的适配器的写法是广 ...

  6. vs编写x64内联汇编

    参考自: https://www.cnblogs.com/achillis/p/5369658.html 先转过来, 等实践过了再做相应的修改, hehe 编写涉及系统特性的一些底层程序,特别是She ...

  7. linux 安装中文支持

    下载  fonts-chinese-3.02-12.el5.noarch.rpm fonts-ISO8859-2-75dpi-1.0-17.1.noarch.rpm 安装各种提示的依赖 安装 chkf ...

  8. 自定义项目启动初始化信息的listener报错

    自定义初始化组件代码如下: @Component public class InitComponent implements ServletContextListener, ApplicationCo ...

  9. vue登录注册及token验证

    // router.jsimport Vue from 'vue'import VueRouter from 'vue-router' Vue.use(VueRouter) const routes ...

  10. ubuntu python的升级与回滚

    转自:https://www.cnblogs.com/wmr95/p/7637077.html 正常情况下,你安装好ubuntu16.04版本之后,系统会自带 python2.7版本,如果需要下载新版 ...