sql-serverhadoophbasehdfssqoop

Sqoop Import HBase - SQL Database


I want to to migrate my data from SQL database to HBase. One of my problem is my SQL tables don't have a Primary key so to overcome this. I am using Composite Key in Sqoop query. I have successfully imported data from SQL to HBase, but the main problem is that the imported data doesn't consist of columns which are used for Candidate Key which are required with data imported. Kindly give some resolution to this.

Sqoop query which I am currently using is of below format:

sqoop import --connect "jdbc:sqlserver://Ip:1433;database=dbname;username=test;password=test" --table TableName --hbase-create-table --hbase-table TableName --column-family NameSpace --hbase-row-key Candidate1,Candidate2,Candidate3 -m 1

Also let me know if anyone knows a query to import the complete database for the same rather then single table.


Solution

  • After lots of research, I came across a correct syntax through which I was able to load all the data correctly without losing any of the single columns as below:

    sqoop import -D sqoop.hbase.add.row.key=true –connect “jdbc:sqlserver://IP:1433;database=DBNAME;username=UNAME;password=PWD” --table SQLTABLENAME –hbase-create-table –hbase-table HBASETABLENAME –column-family COLUMNFAMILYNAME –hbase-row-key PRIMARYKEY -m 1
    

    OR

    sqoop import -D sqoop.hbase.add.row.key=true –connect “jdbc:sqlserver://IP:1433;database=DBNAME;username=UNAME;password=PWD” --table SQLTABLENAME –hbase-create-table –hbase-table HBASETABLENAME –column-family COLUMNFAMILYNAME –hbase-row-key CANDIDATEKEY1, CANDIDATEKEY2, CANDIDATEKEY3 -m 1