Sqoop User Guide (v1.3.0-cdh3u2)(sqoop用户手册)2

来源:互联网 发布:淘宝的衣服能买吗 编辑:程序博客网 时间:2024/05/16 07:24

6. Sqoop Tools

6.1. Using Command Aliases
6.2. Controlling the Hadoop Installation
6.3. Using Generic and Specific Arguments
6.4. Using Options Files to Pass Arguments
6.5. Using Tools
6.1。使用命令别名
6.2。控制Hadoop的安装
6.3。使用一般和具体参数
6.4。使用选项文件来传递参数
6.5。使用工具


Sqoop is a collection of related tools. To use Sqoop, you specify the tool you want to use and the arguments that control the tool.
Sqoop相关工具集合若要使用Sqoop指定您要使用的工具和该工具的参数​​。

If Sqoop is compiled from its own source, you can run Sqoop without a formal installation process by running the bin/sqoop program. Users of a packaged deployment of Sqoop (such as an RPM shipped with Cloudera’s Distribution for Hadoop) will see this program installed as /usr/bin/sqoop. The remainder of this documentation will refer to this program as sqoop. For example:
如果Sqoop编译,你可以在没有一个正式安装的sqoop运行bin /sqoop。使用Sqoop打包部署(如Cloudera一个sqoop的RPM安装此程序/ usr /bin/ sqoop本文档其余部分将参照这一方案例如

$ sqoop tool-name [tool-arguments]
Sqoop ships with a help tool. To display a list of all available tools, type the following command:
soop也有help命令,显示所有可用的工具列表键入以下命令

$ sqoop helpusage: 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  list-databases     List available databases on a server  list-tables        List available tables in a database  version            Display version informationSee 'sqoop help COMMAND' for information on a specific command.

You can display help for a specific tool by entering: sqoop help (tool-name); for example, sqoop help import.

You can also add the --help argument to any command: sqoop import --help.

您可以显示特定的工具帮助
您还可以添加任何命令 


6.1. Using Command Aliases

6.1。使用命令别名

In addition to typing the sqoop (toolname) syntax, you can use alias scripts that specify the sqoop-(toolname) syntax. For example, the scripts sqoop-importsqoop-export, etc. each select a specific tool.
除了使用sqooptoolname语法,您可以使用别名指定sqoop-(toolname)语法脚本例如,脚本sqoop-importsqoop-export等,每个选择特定的工具。

6.2. Controlling the Hadoop Installation

6.2。控制Hadoop的安装

6.3. Using Generic and Specific Arguments

To control the operation of each Sqoop tool, you use generic and specific arguments.
控制每个Sqoop工具操作,您可以使用通用的和具体的参数

For example:
$ sqoop help importusage: sqoop import [GENERIC-ARGS] [TOOL-ARGS]Common arguments:   --connect <jdbc-uri>     Specify JDBC connect string   --connect-manager <jdbc-uri>     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[...]Generic Hadoop command-line arguments:(must preceed any tool-specific arguments)Generic options supported are-conf <configuration file>     specify an application configuration file-D <property=value>            use value for given property-fs <local|namenode:port>      specify a namenode-jt <local|jobtracker:port>    specify a job tracker-files <comma separated list of files>    specify comma separated files to be copied to the map reduce cluster-libjars <comma separated list of jars>    specify comma separated jar files to include in the classpath.-archives <comma separated list of archives>    specify comma separated archives to be unarchived on the compute machines.The general command line syntax isbin/hadoop command [genericOptions] [commandOptions]

6.4. Using Options Files to Pass Arguments

6.4。使用选项文件来传递参数

When using Sqoop, the command line options that do not change from invocation to invocation can be put in an options file for convenience. An options file is a text file where each line identifies an option in the order that it appears otherwise on the command line. Option files allow specifying a single option on multiple lines by using the back-slash character at the end of intermediate lines. Also supported are comments within option files that begin with the hash character. Comments must be specified on a new line and may not be mixed with option text. All comments and empty lines are ignored when option files are expanded. Unless options appear as quoted strings, any leading or trailing spaces are ignored. Quoted strings if used must not extend beyond the line on which they are specified.
使用Sqoop可以在使用选项文件来方便操作选项文件是一个文本文件,其中每行标识顺序选项否则,为命令行通过在行尾使用反斜杠,选项文件允许在多行文本中指定一个参数,还支持以#开头的注释。注释必须指定新行选项文件被使用所有的注释空行被忽略除非选项将显示带引号的字符串任何开头或结尾空格将被忽略。

Option files can be specified anywhere in the command line as long as the options within them follow the otherwise prescribed rules of options ordering. For instance, regardless of where the options are loaded from, they must follow the ordering such that generic options appear first, tool specific options next, finally followed by options that are intended to be passed to child programs.
选项文件可以指定在任何地方,除非对顺序有要求的选项

To specify an options file, simply create an options file in a convenient location and pass it to the command line via --options-file argument.
指定一个选项文件,只需创建一个选项文件在方便的位置通过它的命令行 --options-file进行加载
For example,
$ 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--connectjdbc:mysql://localhost/db--usernamefoo

## Options file for Sqoop import## Specifies the tool being invokedimport# Connect parameter and value--connectjdbc:mysql://localhost/db# Username parameter and value--usernamefoo## Remaining options should be specified in the command line.#

原创粉丝点击