Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
On this page

Submitting a Sqoop Job

Updated on 2024-11-29 GMT+08:00

Scenario

This section outlines the procedure for submitting a Sqoop job using the Oozie client.

NOTE:
  • Parameters that facilitate the automatic creation and deletion of HCatalog tables, such as Sqoop's options --create-hcatalog-table and --drop-and-create-hcatalog-table, are not applicable for data imports using Sqoop. It is necessary to pre-create the required tables in Oozie. To leverage the automatic table creation feature, perform data import using the --hive-import method.
  • If Kerberos authentication is enabled for the cluster (the cluster is in security mode), it is not possible to use the Oozie client for direct Sqoop task submissions to HBase. Instead, execute the Sqoop command for data imports or conduct operations on a normal cluster.

Prerequisites

  • The Sqoop and Oozie components and clients have been installed and are running properly.
  • Obtain the URL of the Oozie service and the IP address and port number of the active Yarn ResourceManager node.
    • The URL of the Oozie service is https://Host IP address of the Oozie instance:Port number/oozie. For example, you can use https://10.1.130.11:21003/oozie to specify the Oozie server that runs the Sqoop task.

      Log in to FusionInsight Manager, choose Cluster > Services > Oozie and click Instances to check the IP address of any Oozie instance. Click Configurations and search for OOZIE_HTTPS_PORT in the search box to check the port number in use.

    • The IP address and port number of the active Yarn ResourceManager node are used to modify the resourceManager parameter in the job.properties file. The format is Active ResourceManager IP address:Port number, for example, 10.1.130.11:8032.

      Log in to FusionInsight Manager, choose Cluster > Services > Yarn and click Instances to check the IP address of the active ResourceManager instance. Click Configurations and search for yarn.resourcemanager.port in the search box to check the port number in use.

  • Upload the JDBC driver JAR package (for example, MySQL driver package mysql-connector-java-5.1.47.jar) of the corresponding relational database version to the /user/oozie/share/lib/sqoopclient/ directory of HDFS, and change the permission and user group to be the same as those of other JAR packages in the directory, perform either of the following operations to update the JAR package dependency:
    • Refresh the dependency on the Oozie client.

      oozie admin -oozie https://Host IP address of the Oozie instance:Port number/oozie -sharelibupdate

    • Restart the Oozie service to refresh the dependency.

      Log in to FusionInsight Manager and choose Cluster > Services > Oozie. On the page that is displayed, choose More > Restart Service to restart the Oozie service.

  • You have obtained the JDBC driver JAR package of the corresponding relational database version, for example, the MySQL driver package mysql-connector-java-5.1.47.jar.
  • The corresponding Sqoop command has been prepared. For details, see .

Procedure

  1. Create a human-machine user for accessing the Oozie service. (Skip this step if a user with related permissions already exists.)

    1. Log in to FusionInsight Manager and choose System > Permission.
    2. Click Role and click Create Role.
      • Role Name: Enter a role name, for example, oozieadmin.
      • Configure Resource Permission: Click the name of the desired cluster, click Oozie, and select Admin.
    3. Choose User in the navigation pane and click Create on the displayed page. Create a human-machine user.
      • Username: Enter the username, for example, admin123.
      • User Type: Select Human-Machine.
      • Password and Confirm Password: Enter a password and enter it again for confirmation.
      • User Group: Add the user to the hadoop, supergroup, and hive user groups.
      • Role: Click Add and bind manager_viewer and the role (for example, oozieadmin) that has the Oozie administrator permissions added in 1.b.
    4. Log in to FusionInsight Manager as the new user and change the initial password.

  2. Log in to the node where the client is installed as the client installation user.
  3. Configure environment variables. /opt/client is an example client installation path.

    source /opt/client/bigdata_env

  4. Check the cluster authentication mode.

    • Kerberos authentication has been enabled for the cluster. Run the kinit command to authenticate users.

      For example, the oozieuser user is authenticated using the following command:

      kinit oozieuser

    • If Kerberos authentication is not enabled for the cluster, go to 5.

  5. Go to the Sqoop sample directory.

    cd /opt/client/Oozie/oozie-client-*/examples/apps/sqoopclient/

    NOTE:
    • Sqoop supports two workflow compilation methods: sqoopclient and sqoopclient-freeform. The distinction between them is confined to the format of the Sqoop command parameters within the workflow.xml file.
    • The sqoopclient-freeform method can be utilized identically to the sqoopclient method. Here are some guidelines for using sqoopclient.
    • If the actual parameter in the Sqoop command contains spaces, use /opt/client/Oozie/oozie-client-*/examples/apps/sqoopclient-freeform as an example. For details, see workflow.xml in the path.

      For example, the Sqoop command contains the parameter --query'select TT.I, TT.S from TT where $CONDITIONS' , and the select statement of the command contains spaces.

  6. Modify the job.properties file.

    vim job.properties

    Perform the following modifications:

    • Change the value of resourceManager to the IP address and port number of the active ResourceManager node of Yarn, for example, resourceManager=10.1.130.11:8032.
    • Change the value of userName to the name of the human-machine user who submits the task, that is, the user name created in 1, for example, userName=oozieuser. This parameter is used to combine the HDFS user path used by Oozie Job.
    • Change the value of user.name to the name of the human-machine user who submits the task, that is, the user name created in 1, for example, user.name=oozieuser. This parameter specifies the user who submits the task.
    • In a multi-cluster environment, change the value of nameNode to the value of fs.defaultFS of the Oozie service in the corresponding cluster.

    In the following example, the resourceManager, userName, and user.name parameters are modified. Retain the default values for other parameters.

    nameNode=hdfs://hacluster
    resourceManager=10.1.130.11:8032
    queueName=default
    examplesRoot=examples
    userName=oozieuser
    user.name=oozieuser
    oozie.use.system.libpath=true
    oozie.wf.application.path=${nameNode}/user/${userName}/${examplesRoot}/apps/sqoop

  7. Modify the workflow.xml file:

    • Kerberos authentication is disabled for the cluster (the cluster is in normal mode)

      vim workflow.xml

      Below is an example of importing data from a MySQL database to Hive. The bolded content should be adjusted accordingly.

      <workflow-app xmlns="uri:oozie:workflow:1.0" name="sqoopclient-wf">
          <start to="sqoopclient-node"/>
      
          <action name="sqoopclient-node">
              <sqoopclient xmlns="uri:oozie:sqoopclient-action:1.0">
                  <resource-manager>${resourceManager}</resource-manager>
                  <name-node>${nameNode}</name-node>
                  <prepare>
                      <delete path="${nameNode}/user/${userName}/${examplesRoot}/output-data/sqoopclient"/>
                      <mkdir path="${nameNode}/user/${userName}/${examplesRoot}/output-data"/>
                  </prepare>
                  <configuration>
                      <property>
                          <name>mapred.job.queue.name</name>
                          <value>${queueName}</value>
                      </property>
                  </configuration>
                  <!--   Specify a specific Sqoop command. Do not add sqoop at the beginning of the command. Do not write sqoop import. Do not use single or double quotation marks to quote the database password. -->
                  <command>import --connect jdbc:mysql://mysql_host_ip:3306/database --username xxx --password xxx --table xxx --hive-import --hive-table xxx --delete-target-dir --fields-terminated-by "," -m 1 --as-textfile</command>
                  <!--   Specify the HDFS configuration file to be used. This parameter should only be specified if explicitly required.-->
                  <file>/user/oozie/share/lib/sqoopclient/hive-site.xml#hive-site.xml</file> 
              </sqoopclient>
              <ok to="end"/>
              <error to="fail"/>
          </action>
      
          <kill name="fail">
              <message>Sqoop client failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
          </kill>
          <end name="end"/>
      </workflow-app>
    • Kerberos authentication is enabled for the cluster (the cluster is in security mode)

      cp workflow.xml.security workflow.xml

      vim workflow.xml

      Below is an example of importing data from a MySQL database to Hive. The bolded content should be adjusted accordingly.
      <workflow-app xmlns="uri:oozie:workflow:1.0" name="sqoopclient-wf">
          <credentials>
            <credential name='hcat_auth' type='hcat'>
               <property>
                  <name>hcat.metastore.uri</name>
                  <!--  The value can be obtained from hive.metastore.uris in hive-site.xml. For example, you can obtain the value from Client installation directory/Hive/config/hive-site.xml.
                  <value>thrift://172.19.xxx.xxx:9083,thrift://172.xxx.xxx.xxx:9083</value>
               </property>
               <property>
                  <name>hcat.metastore.principal</name>
                  <!--  The value can be obtained from hive.metastore.kerberos.principal in hive-site.xml. For example, you can obtain the value from Client installation directory/Hive/config/hive-site.xml.
                  <value>hive/hadoop.xxx.com@XXX_XXX_XXX_XXX_XXX.COM</value>
               </property>
            </credential>
          </credentials>
      
          <start to="sqoopclient-node"/>
      
          <action name="sqoopclient-node" cred='hcat_auth'>
              <sqoopclient xmlns="uri:oozie:sqoopclient-action:1.0">
                  <resource-manager>${resourceManager}</resource-manager>
                  <name-node>${nameNode}</name-node>
                  <prepare>
                      <delete path="${nameNode}/user/${userName}/${examplesRoot}/output-data/sqoopclient"/>
                      <mkdir path="${nameNode}/user/${userName}/${examplesRoot}/output-data"/>
                  </prepare>
                  <configuration>
                      <property>
                          <name>mapred.job.queue.name</name>
                          <value>${queueName}</value>
                      </property>
                  </configuration>
                  <!--   Specify a specific Sqoop command. Do not add sqoop at the beginning of the command. Do not write sqoop import. Do not use single or double quotation marks to quote the database password. -->
                  <command>import --connect jdbc:mysql://mysql_host_ip:3306/database --username xxx --password xxx --table xxx --hive-import --hive-table xxx --delete-target-dir --fields-terminated-by "," -m 1 --as-textfile</command>
                  <!--   Specify the HDFS configuration file to be used. This parameter should only be specified if explicitly required.-->
                  <file>/user/oozie/share/lib/sqoopclient/hive-site.xml#hive-site.xml</file> 
              </sqoopclient>
              <ok to="end"/>
              <error to="fail"/>
          </action>
      
          <kill name="fail">
              <message>Sqoop client failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
          </kill>
          <end name="end"/>
      </workflow-app>

  8. Upload the workflow.xml file to the HDFS path specified by oozie.wf.application.path in the job.properties file.

    hadoop fs -put -f workflow.xml /user/oozieuser/examples/apps/sqoopclient

    NOTE:
    • If the path does not exist, run the following command to create one:

      hadoop fs -mkdir -p /user/oozieuser/examples/apps/sqoopclient

    • Each modification to the workflow.xml file on the client requires re-uploading the file to HDFS prior to executing the Oozie job command.

  9. Run the oozie job command to run the workflow file.

    oozie job -oozie https://Host IP address of the Oozie instance:Port number/oozie/ -config job.properties -run

    NOTE:
    • The command parameters are described as follows:
      • -oozie: URL of the Oozie server that actually executes the Sqoop task
      • -config: Workflow property file
      • -run: Executing a workflow
    • If the job ID is displayed after the workflow file is executed, the submission is successful. The following is an example.
      job: 0000021-140222101051722-oozie-omm-W

      You can view the execution results on the Oozie web UI.

      Log in to the Oozie web UI at https://IP address of the Oozie role:21003/oozie as user oozieuser.

      On the Oozie web UI, you can view the submitted workflow information based on the job ID in the table on the page.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback