Open Source sqoop-shell Tool Usage Guide

Overview

Sqoop-shell is a shell tool of Loader. All its functions are implemented by executing the sqoop2-shell script.

The sqoop-shell tool provides the following functions:

The sqoop-shell tool supports the following modes:

The sqoop-shell implements functions of Loader by running the commands in Table 1.

Table 1 Command list

Command

Description

exit

Exists the interaction mode.

This command is supported only in the interaction mode.

history

Views the executed commands.

This command is supported only in the interaction mode.

help

Views the tool help information.

set

Sets server attributes.

show

Displays service attributes and all the metadata information of Loader.

create

Creates connectors and jobs.

update

Updates connectors and jobs.

delete

Deletes connectors and jobs.

clone

Clones connectors and jobs.

start

Starts jobs.

stop

Stops jobs.

status

Views job status.

Commands

Extended Attributes of Create Command

For the scenario in which HDFS exchanges data with the SFTP server or RDB, MRS extends the create command attributes on the basis of the open source sqoop-shell tool, so as to specify line and field separators and conversion steps when jobs are created.

Table 2 Extended Attributes of Create Command

Property

Description

fields-terminated-by

Default field separator.

lines-terminated-by

Default line separator.

input-fields-terminated-by

Inputs the step field separator. If the step field separator is not specified, the value equals to fields-terminated-by by default.

input-lines-terminated-by

Inputs the step line separator. If the step line separator is not specified, the value equals to lines-terminated-by by default.

output-fields-terminated-by

Outputs the step field separator. If the step field separator is not specified, the value equals to fields-terminated-by by default.

output-lines-terminated-by

Outputs the step line separator. If the step line separator is not specified, the value equals to lines-terminated-by by default.

trans

Specifies the conversion steps. The value is the directory where the conversion step file is located. When the relative directory of file is specified, the file is by default stored in the directory where the sqoop2-shell script is located. When the attribute is set, the other extended attributes can be ignored.

Interconnecting Sqoop1 with MRS

  1. Download the open source Sqoop from http://www.apache.org/dyn/closer.lua/sqoo:p/1.4.7.
  2. Save the downloaded sqoop-1.4.7.bin__hadoop-2.6.0.tar.gz package to the /opt/sqoop directory on the Master node in the MRS cluster and decompress the package.

    tar zxvf sqoop-1.4.7.bin__hadoop-2.6.0.tar.gz

  3. Go to the directory where the package is decompressed and modify the configuration.

    cd /opt/sqoop/sqoop-1.4.7.bin__hadoop-2.6.0/conf

    cp sqoop-env-template.sh sqoop-env.sh

    vi sqoop-env.sh

    Add the following configurations:

    export HADOOP_COMMON_HOME=/opt/client/HDFS/hadoop

    export HADOOP_MAPRED_HOME=/opt/client/HDFS/hadoop

    export HIVE_HOME=/opt/Bigdata/MRS_1.9.X/install/FusionInsight-Hive-3.1.0/hive (Enter the actual path.)

    export HIVE_CONF_DIR=/opt/client/Hive/config

    export HCAT_HOME=/opt/client/Hive/HCatalog

  1. Add the system variable SQOOP_HOME to PATH.

    vi /etc/profile

    Add the following information:

    export SQOOP_HOME=/opt/sqoop/sqoop-1.4.7.bin__hadoop-2.6.0

    export PATH=$PATH:$SQOOP_HOME/bin

  2. Run the following command to copy the jline-2.12.jar file to the lib file.

    cp /opt/share/jline-2.12/jline-2.12.jar /opt/sqoop/sqoop-1.4.7.bin__hadoop-2.6.0/lib

  3. Run the following command to add the following configuration to the file.

    vim $JAVA_HOME/jre/lib/security/java.policy

    permission javax.management.MBeanTrustPermission "register";

  4. Run the following command to interconnect sqoop1 with MRS.

    source /etc/profile