Home Forums HBase Error while connecting to HBase remotely through Java

Tagged: 

This topic contains 6 replies, has 3 voices, and was last updated by  Larry Liu 1 year, 8 months ago.

  • Creator
    Topic
  • #18562

    anups
    Member

    Hi
    When i try to connect to HBase remotely i will get below error. But no issues while i run it from same server .
    Below error recieved in eclipse console :
    13/03/22 16:25:22 ERROR hbase.HServerAddress: Could not resolve the DNS name of anupama
    java.lang.IllegalArgumentException: hostname can’t be null

    Below is my /etchosts file:
    13/03/22 16:25:22 ERROR hbase.HServerAddress: Could not resolve the DNS name of anupama
    java.lang.IllegalArgumentException: hostname can’t be null
    Any suggestions ??

Viewing 6 replies - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.

  • Author
    Replies
  • #19039

    Larry Liu
    Moderator

    Hi, Anups

    I did a bit more research on HTable. I think this is used when you want to do something with the existing table.

    Please let me know if you need anything else.

    Thanks
    Larry

    Collapse
    #19010

    anups
    Member

    Thanks a lot Larry,

    tried with your code and it worked !!!

    Regards
    Anups

    Collapse
    #18893

    Larry Liu
    Moderator

    Hi, Anups,

    From your source code, it seems the createTable is not called since it is commented.
    // createTable(config);

    Also I am not sure this is the correct code to create a table from java api. Here are some codes which will work:
    ############
    HBaseConfiguration hc = new HBaseConfiguration( new Configuration( ) );

    HTableDescriptor ht = new HTableDescriptor( “mytable” );
    // we’ll use the call start time as a row key
    ht.addFamily( new HColumnDescriptor( “number:” ) ); // from and to
    ht.addFamily( new HColumnDescriptor( “company:” ) );
    ht.addFamily( new HColumnDescriptor( “time:” ) ); // billing seconds
    ht.addFamily( new HColumnDescriptor( “location:” ) ); // rate center city 1, state 1 and city 2, state 2

    System.out.println( “connecting…” );
    HBaseAdmin hba = new HBaseAdmin( hc );
    System.out.println( “creating table…” );
    hba.createTable( ht );
    System.out.println( “done!” );
    ##############

    Thanks.
    Larry

    Collapse
    #18828

    anups
    Member

    Hi
    I added the ip of linux machine which i was to connect remotely in my windows machine and that error was gone .
    But now am receiving a different error ie : “org.apache.hadoop.hbase.TableNotFoundException: Cannot find row in .META. for my table ” .
    Am writing a code to create a table in HBase remotely. Below is code :
    public class CreateTable {
    public static void main(String[] agrs) {
    // CONFIGURATION

    // ENSURE RUNNING
    try {
    Configuration hbaseConfig ;
    hbaseConfig = HBaseConfiguration.create();
    hbaseConfig.set(“hbase.zookeeper.quorum”, “192.168.36.21”);
    hbaseConfig.set(“hbase.zookeeper.property.clientPort”,”2181″);
    /* hbaseConfig.set(“hbase.master”, “anupama:60000″); */
    //*HBaseConfiguration config = HBaseConfiguration.create();
    //config.set(“hbase.zookeeper.quorum”, “localhost”); // Here we are running zookeeper locally
    HBaseAdmin.checkHBaseAvailable(hbaseConfig);
    System.out.println(“HBase is running!”);
    // createTable(config);
    //creating a new table
    HTable table = new HTable(hbaseConfig, “mytable”);
    System.out.println(“Table mytable obtained “);
    /* addData(table); */
    }
    catch (MasterNotRunningException e) {
    System.out.println(“HBase is not running!”);
    System.exit(1);
    }catch (Exception ce){ ce.printStackTrace(); }

    }

    private static void addData(HTable table) {
    // TODO Auto-generated method stub

    }
    }

    Collapse
    #18802

    anups
    Member

    Hi
    I am really sorry.. Please find the below /etc/hosts file
    192.168.36.21 anupama
    #127.0.0.1 localhost localhost.localdomain
    #192.168.36.21 localhost localhost.localdomain
    ::1 localhost6.localdomain6 localhost

    Regards
    Anups

    Collapse
    #18568

    tedr
    Member

    Hi Anups,

    Thanks for using Hortonworks Data Platform.

    Unfortunately you posted you error message where you intended to post your /etc/hosts file so I cannot tell if any thing is incorrect in your /etc/hosts.

    Please repost your /etc/hosts file.

    Thanks,
    Ted.

    Collapse
Viewing 6 replies - 1 through 6 (of 6 total)