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

  • 相关阅读:
    windows版本nginx帮助文档
    angular渲染超链接bug
    ionic踩过的一些坑
    ionic项目中使用自定义图标打包出现错误-broken import
    ionic项目中使用自定义图标
    ionic3运行时gradle下载失败的解决方法
    阿里云菜鸡上云实例
    如何用手机控制pc鼠标——Java开发与学习记实
    LeetCode刷题笔记---6月
    编译原理复习题
  • 原文地址:https://www.cnblogs.com/tudousiya/p/11241275.html
Copyright © 2011-2022 走看看