连接到hbase时出错

时间:2015-10-09 12:18:40

标签: java hadoop hbase

我正在尝试与非分布式模式下配置的HBase建立远程连接。 我的代码在java playframework中是以下代码:

    // Instantiating a configuration class
    Configuration hbaseConfiguration = HBaseConfiguration.create();
    try {
        Configuration newConfig = new Configuration(hbaseConfiguration);
        newConfig.set("hbase.zookeeper.quorum", "77.154.69.181");
        newConfig.set("hbase.zookeper.property.clientPort", "2181");
        HConnection connection = HConnectionManager
                .getConnection(newConfig);
       HBaseAdmin hBaseAdmin = new HBaseAdmin(connection);
        if (!hBaseAdmin.isMasterRunning())
            throw new Exception("Hbase is not running");
    } catch (Exception e) {
        e.printStackTrace();
    }

我收到以下错误:

    [error] org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: org.apache.hadoop.net.ConnectTimeoutException: 10000 millis timeout while waiting for channel to be ready for connect. ch : java.nio.channels.SocketChannel[connection-pending remote=vm-77446.localdomain/77.154.69.181:37027]
[error]     at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation$StubMaker.makeStub(ConnectionManager.java:1485)
[error]     at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation$MasterServiceStubMaker.makeStub(ConnectionManager.java:1505)
[error]     at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation.getKeepAliveMasterService(ConnectionManager.java:1711)
[error]     at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation.isMasterRunning(ConnectionManager.java:876)
[error]     at org.apache.hadoop.hbase.client.HBaseAdmin.isMasterRunning(HBaseAdmin.java:271)
[error]     at controllers.Application.index(Application.java:29)
[error]     at router.Routes$$anonfun$routes$1$$anonfun$applyOrElse$1$$anonfun$apply$1.apply(Routes.scala:95)
[error]     at router.Routes$$anonfun$routes$1$$anonfun$applyOrElse$1$$anonfun$apply$1.apply(Routes.scala:95)
[error]     at play.core.routing.HandlerInvokerFactory$$anon$4.resultCall(HandlerInvoker.scala:136)
[error]     at play.core.routing.HandlerInvokerFactory$JavaActionInvokerFactory$$anon$14$$anon$3$$anon$1.invocation(HandlerInvoker.scala:127)
[error]     at play.core.j.JavaAction$$anon$1.call(JavaAction.scala:70)
[error]     at play.http.DefaultHttpRequestHandler$1.call(DefaultHttpRequestHandler.java:20)
[error]     at play.core.j.JavaAction$$anonfun$7.apply(JavaAction.scala:94)
[error]     at play.core.j.JavaAction$$anonfun$7.apply(JavaAction.scala:94)
[error]     at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
[error]     at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
[error]     at play.core.j.HttpExecutionContext$$anon$2.run(HttpExecutionContext.scala:40)
[error]     at play.api.libs.iteratee.Execution$trampoline$.execute(Execution.scala:70)
[error]     at play.core.j.HttpExecutionContext.execute(HttpExecutionContext.scala:32)
[error]     at scala.concurrent.impl.Future$.apply(Future.scala:31)
[error]     at scala.concurrent.Future$.apply(Future.scala:492)
[error]     at play.core.j.JavaAction.apply(JavaAction.scala:94)
[error]     at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4$$anonfun$apply$5.apply(Action.scala:105)
[error]     at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4$$anonfun$apply$5.apply(Action.scala:105)
[error]     at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
[error]     at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4.apply(Action.scala:104)
[error]     at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4.apply(Action.scala:103)
[error]     at scala.Option.map(Option.scala:146)
[error]     at play.api.mvc.Action$$anonfun$apply$1.apply(Action.scala:103)
[error]     at play.api.mvc.Action$$anonfun$apply$1.apply(Action.scala:96)
[error]     at play.api.libs.iteratee.Iteratee$$anonfun$mapM$1.apply(Iteratee.scala:524)
[error]     at play.api.libs.iteratee.Iteratee$$anonfun$mapM$1.apply(Iteratee.scala:524)
[error]     at play.api.libs.iteratee.Iteratee$$anonfun$flatMapM$1.apply(Iteratee.scala:560)
[error]     at play.api.libs.iteratee.Iteratee$$anonfun$flatMapM$1.apply(Iteratee.scala:560)
[error]     at play.api.libs.iteratee.Iteratee$$anonfun$flatMap$1$$anonfun$apply$13.apply(Iteratee.scala:536)
[error]     at play.api.libs.iteratee.Iteratee$$anonfun$flatMap$1$$anonfun$apply$13.apply(Iteratee.scala:536)
[error]     at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
[error]     at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
[error]     at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:40)
[error]     at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:397)
[error]     at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
[error]     at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
[error]     at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
[error]     at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

2 个答案:

答案 0 :(得分:1)

    newConfig.set("hbase.zookeper.property.clientPort", "2181");

应该是

    newConfig.set("hbase.zookeeper.property.clientPort", "2181");

你的代码中有拼写错误。

答案 1 :(得分:1)

从此" org.apache.hadoop.hbase.MasterNotRunningException",您的hbase主服务器(HMaster)未运行。尝试从浏览器打开http://MasterIp:60010并检查您的主服务器是否正在运行(应列出包含表名的Hbase主页)。

如果master正在运行,请添加

    newConfig.set("hbase.master","MasterIP:60000");

正下方

   newConfig.set("hbase.zookeeper.property.clientPort", "2181");