分享

HBase Api客户端访问卡住

一颗银杏树 发表于 2017-4-18 21:42:52 [显示全部楼层] 回帖奖励 阅读模式 关闭右栏 12 23088
一颗银杏树 发表于 2017-4-21 22:44:58
tanxl 发表于 2017-4-19 13:18
/**
         * 创建表
         *

代码增加了一项配置就好了  ,不过还是不能理解为嘛我在eclipse里面加了hbase-site.xml文件,但还是没生效呢。  public void dropTable() throws IOException{
                Configuration conf = HBaseConfiguration.create();
                conf.set("hbase.zookeeper.quorum", "ubuntu3:2181,ubuntu4:2181,ubuntu5:2181");  //增加了这项
                Connection conn = ConnectionFactory.createConnection(conf);
                Admin admin = conn.getAdmin();
                //禁用表
                admin.disableTable(TableName.valueOf("t1"));
                admin.deleteTable(TableName.valueOf("t1"));
                System.out.println("ok");
                admin.close();
        }



没增加这行之前等了好久报下面错误了:
log4j:WARN No appenders could be found for logger (org.apache.hadoop.security.Groups).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" java.net.SocketTimeoutException: callTimeout=1200000, callDuration=5808213: row 'row1' on table 't1' at null
        at org.apache.hadoop.hbase.client.RpcRetryingCaller.callWithRetries(RpcRetryingCaller.java:169)
        at org.apache.hadoop.hbase.client.HTable.get(HTable.java:865)
        at org.apache.hadoop.hbase.client.HTable.get(HTable.java:831)
        at mybasetest.HbaseTest1.main(HbaseTest1.java:27)
Caused by: org.apache.hadoop.hbase.client.RetriesExhaustedException: Can't get the locations
        at org.apache.hadoop.hbase.client.RpcRetryingCallerWithReadReplicas.getRegionLocations(RpcRetryingCallerWithReadReplicas.java:319)
        at org.apache.hadoop.hbase.client.ScannerCallableWithReplicas.call(ScannerCallableWithReplicas.java:156)
        at org.apache.hadoop.hbase.client.ScannerCallableWithReplicas.call(ScannerCallableWithReplicas.java:60)
        at org.apache.hadoop.hbase.client.RpcRetryingCaller.callWithoutRetries(RpcRetryingCaller.java:210)
        at org.apache.hadoop.hbase.client.ClientSmallReversedScanner.loadCache(ClientSmallReversedScanner.java:228)
        at org.apache.hadoop.hbase.client.ClientSmallReversedScanner.next(ClientSmallReversedScanner.java:202)
        at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation.locateRegionInMeta(ConnectionManager.java:1275)
        at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation.locateRegion(ConnectionManager.java:1181)
        at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation.locateRegion(ConnectionManager.java:1165)
        at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation.locateRegion(ConnectionManager.java:1122)
        at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation.getRegionLocation(ConnectionManager.java:957)
        at org.apache.hadoop.hbase.client.HRegionLocator.getRegionLocation(HRegionLocator.java:83)
        at org.apache.hadoop.hbase.client.RegionServerCallable.prepare(RegionServerCallable.java:75)
        at org.apache.hadoop.hbase.client.RpcRetryingCaller.callWithRetries(RpcRetryingCaller.java:134)
        ... 3 more


回复

使用道具 举报

nextuser 发表于 2017-4-22 08:01:07
一颗银杏树 发表于 2017-4-21 22:44
代码增加了一项配置就好了  ,不过还是不能理解为嘛我在eclipse里面加了hbase-site.xml文件,但还是没生 ...

  conf.set("hbase.zookeeper.quorum", "ubuntu3:2181,ubuntu4:2181,ubuntu5:2181");  //增加了这项
这个应该是在本地执行的,而你的本地配置文件中没有设置hbase.zookeeper.quorum。 所以在代码中通过 conf.set是对本地配置文件的设置。
就可以连接上了
回复

使用道具 举报

一颗银杏树 发表于 2017-4-28 16:17:54
nextuser 发表于 2017-4-22 08:01
conf.set("hbase.zookeeper.quorum", "ubuntu3:2181,ubuntu4:2181,ubuntu5:2181");  //增加了这项
这 ...

跟你讲,我还真设置的有,在eclipse里面的类路径下放了一个hbase-site.xml文件,里面设置了这个参数的。调试的时候这个文件里面的参数加载不进去,不知道为嘛,反而在代码里面直接加载才行。
回复

使用道具 举报

12
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条