Book Image

Hadoop MapReduce v2 Cookbook - Second Edition: RAW

Book Image

Hadoop MapReduce v2 Cookbook - Second Edition: RAW

Overview of this book

Table of Contents (19 chapters)
Hadoop MapReduce v2 Cookbook Second Edition
Credits
About the Author
Acknowledgments
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Exporting data from HDFS to a relational database using Apache Sqoop


In this recipe, we'll be using Sqoop2 or Sqoop 1.4.x to export data from HDFS to a PostgreSQL database.

Getting ready

A working Hadoop2 cluster with a Sqoop2 or Sqoop 1.4.x installation is required for this recipe.

We will be using a PostgreSQL database. You can also use another RDBMS for this purpose as well, but the following recipe steps will have to be changed accordingly.

Follow the previous recipe, Importing data to HDFS from a relational database using Apache Sqoop.

How to do it...

This section demonstrates how to export data from HDFS to a PostgreSQL database using SQOOP. Proceed with the following steps:

  1. Follow the step 1 of the previous Importing data to HDFS from a relational database using Apache Sqoop recipe to create a user and a database in the PostgreSQL database.

  2. Create a database table using the following statements in the PostgreSQL shell:

    $ psql test
    test=> CREATE TABLE bookcrossing.ratings_copy
      (user_id...