2

My HBase Version is 1.1.2

And hbase java connector is :

    <dependency>
        <groupId>org.apache.hbase</groupId>
        <artifactId>hbase-client</artifactId>
        <version>1.1.2</version>
    </dependency>

My HBase Cluster has

  • 1 Hmaster : hadoop-153

  • 4 HRegionServer : hadoop-154,hadoop-146,hadoop-147,hadoop-148

  • 3 zookeeper(Hbase embedded) : hadoop-146,hadoop-147,hadoop-148

But when I use the code :

    public class HBaseClientOld {
        private static Configuration conf =null;
        static {
                 conf = HBaseConfiguration.create();
        }
        /**
         * @throws IOException
         */
        public void createTable(String tablename, String[] cfs) throws IOException {
            HBaseAdmin admin =new HBaseAdmin(conf);
            System.out.println(conf.get("hbase.master"));
            if (admin.tableExists(tablename)) {
                System.out.println("The Table is existed");
            }
            else {
                HTableDescriptor tableDesc =new HTableDescriptor(tablename);
                for (int i =0; i < cfs.length; i++) {
                    tableDesc.addFamily(new HColumnDescriptor(cfs[i]));
                }
                admin.createTable(tableDesc);
                System.out.println("create table successful");
            }
        }
        public static void main(String[] args) throws IOException {
            HBaseClientOld hbc = new HBaseClientOld();
            hbc.createTable("res", new String[]{"data"});
        }
    }

But When I run the code,there is a exception:

    Exception in thread "main" org.apache.hadoop.hbase.client.RetriesExhaustedException: Failed after attempts=36, exceptions:
    Tue Dec 15 16:44:00 CST 2015, null, java.net.SocketTimeoutException: callTimeout=60000, callDuration=76198: row 'res,,' on table 'hbase:meta' at region=hbase:meta,,1.1588230740, hostname=hadoop-154,16020,1450168253441, seqNum=0
    ...
    Caused by: java.net.SocketTimeoutException: callTimeout=60000, callDuration=76198: row 'res,,' on table 'hbase:meta' at region=hbase:meta,,1.1588230740, hostname=hadoop-154,16020,1450168253441, seqNum=0
        at org.apache.hadoop.hbase.client.RpcRetryingCaller.callWithRetries(RpcRetryingCaller.java:159)
        at org.apache.hadoop.hbase.client.ResultBoundedCompletionService$QueueingFuture.run(ResultBoundedCompletionService.java:64)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)
    Caused by: java.net.ConnectException: Connection refused: no further information
        at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)

anyone help..

there is the zookeeper log:

    2015-12-15 17:53:47,821 INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181] server.NIOServerCnxnFactory: Accepted socket connection from /ip-client:50354
    2015-12-15 17:53:47,824 INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181] server.ZooKeeperServer: Client attempting to establish new session at /ip-client:50354
    2015-12-15 17:53:47,834 INFO  [SyncThread:0] server.ZooKeeperServer: Established session 0x151a50e5a410010 with negotiated timeout 90000 for client /ip-client:50354
    2015-12-15 17:53:57,638 INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181] server.NIOServerCnxnFactory: Accepted socket connection from /10.128.122.153:59426
    2015-12-15 17:53:57,640 INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181] server.ZooKeeperServer: Client attempting to establish new session at /10.128.122.153:59426
    2015-12-15 17:53:57,651 INFO  [SyncThread:0] server.ZooKeeperServer: Established session 0x151a50e5a410011 with negotiated timeout 90000 for client /10.128.122.153:59426
    2015-12-15 17:54:12,000 INFO  [SessionTracker] server.ZooKeeperServer: Expiring session 0x51a4c3707f0005, timeout of 90000ms exceeded
    2015-12-15 17:54:12,000 INFO  [SessionTracker] server.ZooKeeperServer: Expiring session 0x51a4c3707f0003, timeout of 90000ms exceeded
    2015-12-15 17:54:12,001 INFO  [ProcessThread(sid:0 cport:-1):] server.PrepRequestProcessor: Processed session termination for sessionid: 0x51a4c3707f0005
    2015-12-15 17:54:12,001 INFO  [ProcessThread(sid:0 cport:-1):] server.PrepRequestProcessor: Processed session termination for sessionid: 0x51a4c3707f0003
    2015-12-15 17:54:44,573 WARN  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181] server.NIOServerCnxn: Exception causing close of session 0x151a50e5a410010 due to java.io.IOException: Connection reset by peer
    2015-12-15 17:54:44,574 INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181] server.NIOServerCnxn: Closed socket connection for client /ip-client:50354 which had sessionid 0x151a50e5a410010
    2015-12-15 17:56:15,000 INFO  [SessionTracker] server.ZooKeeperServer: Expiring session 0x151a50e5a410010, timeout of 90000ms exceeded
    2015-12-15 17:56:15,000 INFO  [ProcessThread(sid:0 cport:-1):] server.PrepRequestProcessor: Processed session termination for sessionid: 0x151a50e5a410010
iameven
  • 338
  • 4
  • 15
  • How are you setting config details like HMaster and Zookeeper Quorum to connect to HBase cluster? I do not see those settings in code you have shared – mbaxi Dec 15 '15 at 09:32
  • Also are you able to create new table through HBase shell? – mbaxi Dec 15 '15 at 09:33
  • @mbaxi yes , I can create table by shell – iameven Dec 15 '15 at 09:41
  • Can you check the HBase(and Zookeeper) logs? As far as I see the call is retried several times because is refused(this is what I understand from your stacktrace on the client side) Check on the server side the logs, maybe you can find the the root cause of: java.net.ConnectException: Connection refused: no further information If the logs do not record any call then is from your client configuration most likely check this post: http://javarevisited.blogspot.ro/2013/02/java-net-ConnectException-Connection-refused.html – Flowryn Dec 15 '15 at 09:52
  • Look closer. This is a connection refusal. Nothing was listening at the IP:port you tried to connect to. – user207421 Dec 15 '15 at 10:12
  • Are you running this client from a remote machine? check if the /etc/hosts file has all relevant entries? also is the exception occurring while admin.tableExists() check is made? – mbaxi Dec 15 '15 at 11:56
  • @mbaxi yes,the client is a remote pc,and the exception is at admin.table.Exists() – iameven Dec 16 '15 at 02:20
  • @mbaxi about the hosts file,I add all entries before – iameven Dec 16 '15 at 02:21
  • To check for existence of a table a full scan is done on meta and catalog table, please try to debug in HBase code and see what exactly is missing. I feel that some config it needs is not getting passed correctly or your meta or catalog table may be corrupted....but since you are able to create via shell I doubt that later would be an issue. – mbaxi Dec 16 '15 at 06:48
  • Had the same problem. Restarting HBase and making sure that all hosts know all host names in the cluster mutually (I altered every hosts file manually) did it for me. – Adrian Kiesthardt Jan 05 '18 at 10:40

0 Answers0