HBase Forum

Error while connecting to HBase remotely through Java

  • #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 ??

to create new topics or reply. | New User Registration

  • Author
    Replies
  • #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.

    #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

    #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

    }
    }

    #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

    #19010
    anups
    Member

    Thanks a lot Larry,

    tried with your code and it worked !!!

    Regards
    Anups

    #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

You must be to reply to this topic. | Create Account

Support from the Experts

A HDP Support Subscription connects you experts with deep experience running Apache Hadoop in production, at-scale on the most demanding workloads.

Enterprise Support »

Become HDP Certified

Real world training designed by the core architects of Hadoop. Scenario-based training courses are available in-classroom or online from anywhere in the world

Training »

Hortonworks Data Platform
The Hortonworks Data Platform is a 100% open source distribution of Apache Hadoop that is truly enterprise grade having been built, tested and hardened with enterprise rigor.
Get started with Sandbox
Hortonworks Sandbox is a self-contained virtual machine with Apache Hadoop pre-configured alongside a set of hands-on, step-by-step Hadoop tutorials.
Modern Data Architecture
Tackle the challenges of big data. Hadoop integrates with existing EDW, RDBMS and MPP systems to deliver lower cost, higher capacity infrastructure.