0

Hbase running on Cloudera-quickstart-VM also verified that Zookeeper and Hbase running by using the hbase shell but when I am trying to creating a table using java program then I am getting below error.

public static void main(String[] args) throws IOException {
    Configuration config=new HBaseConfiguration().create();
    config.set("hbase.zookeeper.quorum","sandbox.hortonworks.com");
    config.set("zookeeper.znode.parent", "/hbase-unsecure");
    //config.set("hbase.master", "hostname"+":16000");
    Connection conn=ConnectionFactory.createConnection(config);
    
    Admin admin=conn.getAdmin();
    HTableDescriptor tableName=new HTableDescriptor("notification");
    tableName.addFamily(new HColumnDescriptor("attribute"));
    tableName.addFamily(new HColumnDescriptor("metrics"));
    
    if(!admin.tableExists(tableName.getTableName())) {
        
        System.out.println("create table ...");
        admin.createTable(tableName);
        System.out.println("done");
    }
    
    
}

Find the Cloudera Virtual Box config

[maria_dev@sandbox ~]$ cat /etc/hosts
127.0.0.1       localhost
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.17.0.2      sandbox.hortonworks.com

Find the window hosts file config:

127.0.0.1           localhost
#   ::1             localhost
172.17.0.2          sandbox.hortonworks.com

Error while connecting

2020-07-04 19:09:02 INFO  ClientCnxn:975 - Opening socket connection to server sandbox.hortonworks.com/172.17.0.2:2181. Will not attempt to authenticate using SASL (unknown error)
2020-07-04 19:09:23 WARN  ClientCnxn:1102 - Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: Connection timed out: no further information
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
    at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:350)
    at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081)
2020-07-04 19:09:23 DEBUG ClientCnxnSocketNIO:192 - Ignoring exception during shutdown input
java.nio.channels.ClosedChannelException
    at sun.nio.ch.SocketChannelImpl.shutdownInput(SocketChannelImpl.java:780)
    at sun.nio.ch.SocketAdaptor.shutdownInput(SocketAdaptor.java:399)
    at org.apache.zookeeper.ClientCnxnSocketNIO.cleanup(ClientCnxnSocketNIO.java:189)
    at org.apache.zookeeper.ClientCnxn$SendThread.cleanup(ClientCnxn.java:1185)
    at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1110)
2020-07-04 19:09:23 DEBUG ClientCnxnSocketNIO:199 - Ignoring exception during shutdown output
java.nio.channels.ClosedChannelException
rahul sharma
  • 505
  • 4
  • 17

2 Answers2

0

I dont know it is related or not but create is a static function. It must be
Configuration config=HBaseConfiguration.create();
not
new HBaseConfiguration().create();.
Also be sure, your zookeeper port is 2181. if not, provide it with "hbase.zookeeper.property.clientPort" property.

ozhang
  • 171
  • 9
0

Though it is impossible to pinpoint where exactly the problem could have been created, it seems that you have somehow got 'too much' into the server url:

sandbox.hortonworks.com/172.17.0.2:2181

Presumably either the domain name would work, or the ip address, but both together is invalid.

Also, keep in mind that Hortonworks has merged with Cloudera and there is a successor to HDP, called the Cloudera Data Platform. This is recommended for all new cluster setups. The sandbox equivalent can be accessed here.


Full disclosure: I am an employee of Cloudera (formerly Hortonworks), the company behind both HDP and CDP

Dennis Jaheruddin
  • 21,208
  • 8
  • 66
  • 122