sqoop应用

Sqoop User Guide:
http://sqoop.apache.org/docs/1.4.2/SqoopUserGuide.html#_syntax_11

Sqoop是一个用来将Hadoop和关系型数据库中的数据相互转移的工具,可以将一个关系型数据库(例如 : MySQL ,Oracle ,Postgres等)中的数据导进到Hadoop的HDFS中,也可以将HDFS的数据导进到关系型数据库中。

usage: sqoop COMMAND [ARGS]

Available commands:
  codegen     Generate code to interact with database records
  create-hive-table  Import a table definition into Hive
  eval        Evaluate a SQL statement and display the results
  export             Export an HDFS directory to a database table
  help               List available commands
  import             Import a table from a database to HDFS
  import-all-tables  Import tables from a database to HDFS
  job                Work with saved jobs
  list-databases     List available databases on a server
  list-tables        List available tables in a database
  merge              Merge results of incremental imports
  metastore          Run a standalone Sqoop metastore
  version            Display version information

命令选项文件option files,将选项设置封装在一个文件里:

$ sqoop import --connect jdbc:mysql://localhost/db --username foo --table TEST
$ sqoop --options-file /users/homer/work/import.txt --table TEST
where the options file /users/homer/work/import.txt contains the following:
import
--connect
jdbc:mysql://localhost/db
--username
foo

选项文件可以有空行或者注释:

#
# Options file for Sqoop import
#

# Specifies the tool being invoked
import

# Connect parameter and value
--connect
jdbc:mysql://localhost/db

# Username parameter and value
--username
foo

#
# Remaining options should be specified in the command line.
#

1。sqoop-import
将一个表从一个RDBMS导入到HDFS,

参数                     描述
--connect <jdbc-uri>    Specify JDBC connect string
--connection-manager <class-name>   
        Specify connection manager class to use
--driver <class-name>   
        Manually specify JDBC driver class to use
--hadoop-home <dir> Override $HADOOP_HOME
--help  Print usage instructions
-P  Read password from console
--password <password>   Set authentication password
--username <username>   Set authentication username
--verbose   Print more information while working
--connection-param-file <filename>  
Optional properties file that provides connection parameters

要导入表首先要创建数据库连接

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值