Sunday 22 July 2012

SQOOP Installation

After finishing hadoop and hbase installation  go to apache downloads and remmebr to download sqoop versions from this list
 sqoop-1.4.1-incubating__hadoop-0.20.tar.gz

Exception in thread "main" java.lang.
NoClassDefFoundError:
com/cloudera/sqoop/Sqoop
Caused by: java.lang.ClassNotFoundException: com.cloudera.sqoop.Sqoop
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: com.cloudera.sqoop.Sqoop.  Program will exit.
The source tarball (sqoop-1.4.1-incubating-src.tar.gz<http://apache.tradebit.com/pub/sqoop/1.4.1-incubating/sqoop-1.4.1-incubating-src.tar.gz>) doesn't include Sqoop jar file, so you get that error.
Untar the sqoop to /usr/local/sqoop
[root@master ~]# chown hduser /usr/local/sqoop
[root@master ~]# chown hduser /usr/local/sqoop/conf
[root@master ~]# chown hduser /usr/local/sqoop/connector/mssql
[root@master ~]# chmod 755 /usr/local/sqoop/connector/mssql
[root@master ~]# chmod 755 /usr/local/sqoop/conf
[root@master ~]# chmod 755 /usr/local/sqoop/

download sqoop-sqlserver connector and copy to connectors folder
and run install.sh.Before that you should assign permissions to the folder to install the connector.
Copied hadoop-core-1.0.3.jar in sqoop lib
Copy sqoop-sqlserver-1.0.jar,mysql-connector-java-5.1.21-bin.jar in sqoop lib
Set the environment variables

MSSQL_CONNECTOR_HOME=/usr/local/sqoop/sqoop-sqlserver-1.0/
HADOOP_HOME=/usr/local/hadoop
SQOOP_CONF_DIR=/usr/local/sqoop/conf
SQOOP_HOME=/usr/local/sqoop
HBASE_HOME=/usr/local/hbase-0.92.1/
HADOOP_CLASSPATH=:/usr/local/sqoop/sqoop-1.4.1-incubating.jar

Copy sql jdbc connector (sqljdbc_4.0.2206.100_enu.tar.gz) and extract its two jdbc jars in 
$SQOOP_HOME/lib

Now you are ready to execute import and export commands :)
go to the Downloads directory, unzip the tar and copy the jar fil to /usr/bin/sqoop/lib
  • $ cd Downloads                                                      (assumes starting from the home directory)
  • $ tar -zxvf sqljdbc_4.0.2206.100_enu.tar.gz   (Check the version number you downloaded)
  • $ sudo cp sqljdbc_4.0/enu/sqljdbc4.jar /usr/lib/sqoop/lib
Now we have the JDBC driver in place, we’re ready to install the SQL Server connector, assuming you downloaded it in the step above, unzip the tar, move the directory to /usr/local, set the environment variable and permissions then install it…
  • $ tar -zxvf sqoop-sqlserver-1.0.tar.gz
  • $ sudo mv sqoop-sqlserver-1.0 /usr/local
  • $ export MSSQL_CONNECTOR_HOME=/usr/local/sqoop-sqlserver-1.0
in the Install Hadoop example, we set up a Hadoop group – change the ownership of the sqoop directories now and you’ll save time fiddling around with permissions later.
  • $ sudo chown -R hduser:hadoop /usr/lib/sqoop
  • $ sudo chown -R hduser:hadoop /etc/sqoop
Now install the connector
  • $ cd /usr/local/sqoop-sqlserver-1.0
  • $ ./install.sh

Copy the jar files in hadoop lib as well otherwise i got some errors of connectivity
Enjoy sqooping :)

3 comments:

  1. getting below error, please help me :

    "Connection refused. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".

    My coonection string is :
    sqoop-list-databases –connect jdbc:sqlserver://Sql2005/–username abc –password abc

    ReplyDelete
  2. have u disabled iptables...If not please disable them

    ReplyDelete
  3. Hi All,

    Will you please send me the query for one hive table to multiple sql server tables in sqoop export?

    One hive table to one sql server destination table is working fine. But our requirement is to develop one to many, many to one and many to many relationship is it possible to do it in hadoop?

    Please send me the result as soon as possible...

    ReplyDelete