zoukankan      html  css  js  c++  java
  • hadoop sqoop 实例

    hadoop sqoop (实例)day-1

    sqoop:是一款开源的工具,主要用于在Hadoop与传统的数据库(mysql)间进行数据的传递,可以将一个关系型数据库中的数据导进到Hadoop的HDFS中,也可以将HDFS的数据导进到关系型数据库中。

    实例一:(从mysql中导入表HDFS)

    创建脚本:vim sqoop-customer.sh

    #!/bin/bash

    sqoop import --connect jdbc:mysql://localhost:3306/数据库名 --table customers (customers为mysql表名) --username root --password ok --target-dir /data/user (创建导入hdfs的w文件名)

    实例二:(通过where语句过滤到hdfs)

    #!/bin/bash

    sqoop import --connect jdbc:mysql://localhost:3306/test --table customers --where "customer_id<10" --username root --password ok --delete-target-dir (如果原文件有则删除) --target-dir /data/user/customers

    实例三:(通过columns语句过滤到hdfs)

    #!/bin/bash

    sqoop import --connect jdbc:mysql://localhost:3306/test --table customers --columns "customer_id,customer_fname,customer_lname" --username root --password ok --delete-target-dir --target-dir /data/user/customers

    实例四:(通过select语句过滤到hdfs)

    #!/bin/bash

    sqoop import --connect jdbc:mysql://localhost:3306/test --query "select * from customer where customer_id=1and$CONDITIONS" --username root --password ok --split-by customer_id --delete-target-dir --target-dir /data/user/customers

    实例五:(append追加数据)

    #!/bin/bash

    sqoop import --connect jdbc:mysql://localhost:3306/test --table customers --username root --password ok --where 'customer_id<100' --incremental append --check-column customer_id --last-value 10 --target-dir /data/user/customers

  • 相关阅读:
    JS基础三
    淘宝 NPM 镜像使用
    zepto的tap事件的点透问题的几种解决方案
    Web 通信 之 长连接、长轮询(long polling)(转载)
    命令模式坚决svn树冲突(local unversioned, incoming add upon update)
    svn st 状态详解
    Atom与markdown
    chrome调试创建sq设备进行调试
    webpack 使用教程--实时刷新测试
    前端资源
  • 原文地址:https://www.cnblogs.com/tudousiya/p/11241275.html
Copyright © 2011-2022 走看看