Friday 25 August 2017

1)SQOOP, LIST and EVAL

Apache Sqoop:
Apache Sqoop(TM) is a tool designed for efficiently transferring bulk data between Apache Hadoop and structured datastores such as relational databases.

To run and check sqoop options:


Start by listing first:



1)Command to list databases on mysql databases
Command:
list-databases     List available databases on a server
Syntax:
sqoop list-databases --connect hostaddress --username name --password pass ;

mano@Mano:~$ sqoop list-databases \
> --connect jdbc:mysql://localhost \
> --username root \
> --password root \
> ;

Warning: /home/mano/Hadoop_setup/sqoop-1.4.6.bin__hadoop-2.0.4-alpha/../hbase does not exist! HBase imports will fail.
Please set $HBASE_HOME to the root of your HBase installation.
Warning: /home/mano/Hadoop_setup/sqoop-1.4.6.bin__hadoop-2.0.4-alpha/../hcatalog does not exist! HCatalog jobs will fail.
Please set $HCAT_HOME to the root of your HCatalog installation.
Warning: /home/mano/Hadoop_setup/sqoop-1.4.6.bin__hadoop-2.0.4-alpha/../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
Warning: /home/mano/Hadoop_setup/sqoop-1.4.6.bin__hadoop-2.0.4-alpha/../zookeeper does not exist! Accumulo imports will fail.
Please set $ZOOKEEPER_HOME to the root of your Zookeeper installation.
17/08/25 15:02:11 INFO sqoop.Sqoop: Running Sqoop version: 1.4.6
17/08/25 15:02:11 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
17/08/25 15:02:11 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.
information_schema
metastore
mysql
performance_schema
sqoop_test
sqoopdb

2)Command to list tables on mysql databases
Command:
list-tables        List available tables in a database
Syntax:
sqoop list-tables --connect hostaddress --username name --password pass ;


mano@Mano:~$ sqoop list-tables --connect jdbc:mysql://localhost/sqoop_test --username root --password root ;
Warning: /home/mano/Hadoop_setup/sqoop-1.4.6.bin__hadoop-2.0.4-alpha/../hbase does not exist! HBase imports will fail.
Please set $HBASE_HOME to the root of your HBase installation.
Warning: /home/mano/Hadoop_setup/sqoop-1.4.6.bin__hadoop-2.0.4-alpha/../hcatalog does not exist! HCatalog jobs will fail.
Please set $HCAT_HOME to the root of your HCatalog installation.
Warning: /home/mano/Hadoop_setup/sqoop-1.4.6.bin__hadoop-2.0.4-alpha/../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
Warning: /home/mano/Hadoop_setup/sqoop-1.4.6.bin__hadoop-2.0.4-alpha/../zookeeper does not exist! Accumulo imports will fail.
Please set $ZOOKEEPER_HOME to the root of your Zookeeper installation.
17/08/25 15:02:56 INFO sqoop.Sqoop: Running Sqoop version: 1.4.6
17/08/25 15:02:56 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
17/08/25 15:02:56 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.
employees
mano@Mano:~$

Note :
Difference between list-databases and list-tables
for list-databases - don't need to pass the db name on connection string
Example:
--connect jdbc:mysql://localhost
for list-tables - we must pass the appropriate DB name on connection string
Example:
--connect jdbc:mysql://localhost/sqoop_test

3)Command to evaluate tables on mysql databases

Command:
eval               Evaluate a SQL statement and display the results

Syntax:
sqoop eval --connect hostaddress --username user --password pass --query 'query to run' ;

mano@Mano:~$ sqoop eval \
> --connect jdbc:mysql://localhost/sqoop_test \
> --username root \
> --password root \
> --query 'select * from employees'

Warning: /home/mano/Hadoop_setup/sqoop-1.4.6.bin__hadoop-2.0.4-alpha/../hbase does not exist! HBase imports will fail.
Please set $HBASE_HOME to the root of your HBase installation.
Warning: /home/mano/Hadoop_setup/sqoop-1.4.6.bin__hadoop-2.0.4-alpha/../hcatalog does not exist! HCatalog jobs will fail.
Please set $HCAT_HOME to the root of your HCatalog installation.
Warning: /home/mano/Hadoop_setup/sqoop-1.4.6.bin__hadoop-2.0.4-alpha/../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
Warning: /home/mano/Hadoop_setup/sqoop-1.4.6.bin__hadoop-2.0.4-alpha/../zookeeper does not exist! Accumulo imports will fail.
Please set $ZOOKEEPER_HOME to the root of your Zookeeper installation.
;
17/08/25 15:23:54 INFO sqoop.Sqoop: Running Sqoop version: 1.4.6
17/08/25 15:23:54 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
17/08/25 15:23:54 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.
-----------------------------------------
| id          | name       | city       |
-----------------------------------------
| 1           | Mano       | Chennai    |
| 2           | Prasath    | Chennai    |
| 3           | Chella     | osure      |
-----------------------------------------

2 comments:

  1. Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking.
    Big Data Hadoop Online Course


    ReplyDelete
    Replies
    1. Thanks for the valuable feedback, I would also suggest kindly through on the Labels basis which u could find in the blog top-right and will get more info for specific areas

      Delete

Fundamentals of Python programming

Fundamentals of Python programming: Following below are the fundamental constructs of Python programming: Python Data types Python...