HBase shell 启动出错 org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = Con

一般发生在长期使用hbase,后面再安装之后直接使用hbase shell 想要进入hbase界面,却没有启动start-hbase.sh而导致的。


[root@master local]# hbase shell

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/hbase/lib/slf4j-log4j12-1.7.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/hadoop2/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
2015-05-17 23:11:37,482 ERROR [main] zookeeper.RecoverableZooKeeper: ZooKeeper exists failed after 4 attempts
2015-05-17 23:11:37,484 WARN  [main] zookeeper.ZKUtil: hconnection-0x1623e7c40x0, quorum=master:2181, baseZNode=/hbase Unable to set watcher on znode (/hbase/hbaseid)
org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /hbase/hbaseid
    at org.apache.zookeeper.KeeperException.create(KeeperException.java:99)
    at org.apache.zookeeper.KeeperException.create(KeeperException.java:51)
    at org.apache.zookeeper.ZooKeeper.exists(ZooKeeper.java:1045)
    at org.apache.hadoop.hbase.zookeeper.RecoverableZooKeeper.exists(RecoverableZooKeeper.java:222)
    at org.apache.hadoop.hbase.zookeeper.ZKUtil.checkExists(ZKUtil.java:481)
    at org.apache.hadoop.hbase.zookeeper.ZKClusterId.readClusterIdZNode(ZKClusterId.java:65)
    at org.apache.hadoop.hbase.client.ZooKeeperRegistry.getClusterId(ZooKeeperRegistry.java:86)
    at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation.retrieveClusterId(ConnectionManager.java:833)
    at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation.<init>(ConnectionManager.java:623)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(ConnectionFactory.java:238)
    at org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(ConnectionFactory.java:218)
    at org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(ConnectionFactory.java:119)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.jruby.javasupport.JavaMethod.invokeDirectWithExceptionHandling(JavaMethod.java:450)
    at org.jruby.javasupport.JavaMethod.invokeStaticDirect(JavaMethod.java:362)
    at org.jruby.java.invokers.StaticMethodInvoker.call(StaticMethodInvoker.java:58)
    at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:312)
    at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:169)
    at org.jruby.ast.CallOneArgNode.interpret(CallOneArgNode.java:57)
    at org.jruby.ast.InstAsgnNode.interpret(InstAsgnNode.java:95)
    at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
    at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
    at org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:74)
    at org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:169)
    at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:191)
    at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:302)
    at org.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:144)
    at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:148)
    at org.jruby.RubyClass.newInstance(RubyClass.java:822)
    at org.jruby.RubyClass$i$newInstance.call(RubyClass$i$newInstance.gen:65535)
    at org.jruby.internal.runtime.methods.JavaMethod$JavaMethodZeroOrNBlock.call(JavaMethod.java:249)
    at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:292)
    at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:135)
    at usr.local.hbase.bin.hirb.__file__(/usr/local/hbase/bin/hirb.rb:118)
    at usr.local.hbase.bin.hirb.load(/usr/local/hbase/bin/hirb.rb)
    at org.jruby.Ruby.runScript(Ruby.java:697)
    at org.jruby.Ruby.runScript(Ruby.java:690)
    at org.jruby.Ruby.runNormally(Ruby.java:597)
    at org.jruby.Ruby.runFromMain(Ruby.java:446)
    at org.jruby.Main.doRunFromMain(Main.java:369)
    at org.jruby.Main.internalRun(Main.java:258)
    at org.jruby.Main.run(Main.java:224)
    at org.jruby.Main.run(Main.java:208)
    at org.jruby.Main.main(Main.java:188)
2015-05-17 23:11:37,492 ERROR [main] zookeeper.ZooKeeperWatcher: hconnection-0x1623e7c40x0, quorum=master:2181, baseZNode=/hbase Received unexpected KeeperException, re-throwing exception
org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /hbase/hbaseid
    at org.apache.zookeeper.KeeperException.create(KeeperException.java:99)
    at org.apache.zookeeper.KeeperException.create(KeeperException.java:51)
    at org.apache.zookeeper.ZooKeeper.exists(ZooKeeper.java:1045)
    at org.apache.hadoop.hbase.zookeeper.RecoverableZooKeeper.exists(RecoverableZooKeeper.java:222)
    at org.apache.hadoop.hbase.zookeeper.ZKUtil.checkExists(ZKUtil.java:481)
    at org.apache.hadoop.hbase.zookeeper.ZKClusterId.readClusterIdZNode(ZKClusterId.java:65)
    at org.apache.hadoop.hbase.client.ZooKeeperRegistry.getClusterId(ZooKeeperRegistry.java:86)
    at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation.retrieveClusterId(ConnectionManager.java:833)
    at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation.<init>(ConnectionManager.java:623)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(ConnectionFactory.java:238)
    at org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(ConnectionFactory.java:218)
    at org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(ConnectionFactory.java:119)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.jruby.javasupport.JavaMethod.invokeDirectWithExceptionHandling(JavaMethod.java:450)
    at org.jruby.javasupport.JavaMethod.invokeStaticDirect(JavaMethod.java:362)
    at org.jruby.java.invokers.StaticMethodInvoker.call(StaticMethodInvoker.java:58)
    at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:312)
    at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:169)
    at org.jruby.ast.CallOneArgNode.interpret(CallOneArgNode.java:57)
    at org.jruby.ast.InstAsgnNode.interpret(InstAsgnNode.java:95)
    at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
    at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
    at org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:74)
    at org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:169)
    at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:191)
    at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:302)
    at org.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:144)
    at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:148)
    at org.jruby.RubyClass.newInstance(RubyClass.java:822)
    at org.jruby.RubyClass$i$newInstance.call(RubyClass$i$newInstance.gen:65535)
    at org.jruby.internal.runtime.methods.JavaMethod$JavaMethodZeroOrNBlock.call(JavaMethod.java:249)
    at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:292)
    at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:135)
    at usr.local.hbase.bin.hirb.__file__(/usr/local/hbase/bin/hirb.rb:118)
    at usr.local.hbase.bin.hirb.load(/usr/local/hbase/bin/hirb.rb)
    at org.jruby.Ruby.runScript(Ruby.java:697)
    at org.jruby.Ruby.runScript(Ruby.java:690)
    at org.jruby.Ruby.runNormally(Ruby.java:597)
    at org.jruby.Ruby.runFromMain(Ruby.java:446)
    at org.jruby.Main.doRunFromMain(Main.java:369)
    at org.jruby.Main.internalRun(Main.java:258)
    at org.jruby.Main.run(Main.java:224)
    at org.jruby.Main.run(Main.java:208)
    at org.jruby.Main.main(Main.java:188)
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell

Version 1.0.1, r66a93c09df3b12ff7b86c39bc8475c60e15af82d, Fri Apr 17 22:14:06 PDT 2015



原因 没有启动HBase 需要运行 start-hbase.sh 才可以。

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 8
    评论
这是一个ZooKeeper连接丢失的异常。它表示与ZooKeeper服务器的连接已经丢失,可能是由于网络问题或ZooKeeper服务器不可用引起的。当客户端无法与ZooKeeper服务器建立或保持连接时,会抛出这个异常。 要解决这个问题,可以尝试以下几个步骤: 1. 检查网络连接:确保客户端和ZooKeeper服务器之间的网络连接正常。可以尝试使用ping命令来测试网络连接是否正常。 2. 检查ZooKeeper服务器状态:确保ZooKeeper服务器正在运行并且可用。可以使用zkCli命令行工具连接到ZooKeeper服务器并检查其状态。 3. 检查ZooKeeper配置:检查ZooKeeper客户端的配置文件,确保配置正确并指向正确的ZooKeeper服务器地址和端口。 4. 增加重试机制:在代码中增加重试机制,当连接丢失时,可以尝试重新连接。可以使用ZooKeeper提供的重试策略来实现这个功能。 以下是一个示例代码,演示如何处理这个异常并进行重试: ```java import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.ZooKeeper; public class ZooKeeperConnection { private static final int MAX_RETRIES = 3; private static final int RETRY_INTERVAL = 1000; // 1秒 public static void main(String[] args) { ZooKeeper zooKeeper = null; int retries = 0; while (retries < MAX_RETRIES) { try { zooKeeper = new ZooKeeper("localhost:2181", 5000, null); break; } catch (KeeperException.ConnectionLossException e) { System.out.println("连接丢失,正在尝试重新连接..."); retries++; try { Thread.sleep(RETRY_INTERVAL); } catch (InterruptedException ex) { ex.printStackTrace(); } } catch (Exception e) { e.printStackTrace(); break; } } if (zooKeeper != null && zooKeeper.getState() == ZooKeeper.States.CONNECTED) { System.out.println("成功连接到ZooKeeper服务器"); } else { System.out.println("无法连接到ZooKeeper服务器"); } } } ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值