请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

我在centos上成功部署了kudu,但是在本地WINDOWS用IDEA的时候依旧无法执行您KUDU创建表的的代码,想知道这种情况应该怎么解决?

老师您好,我在centos上成功部署了kudu,并按照您课程的要求修改好相应的配置文件,但是在本地WINDOWS用IDEA的时候依旧无法执行您KUDU创建表的的代码,想知道这种情况应该怎么解决?(防火墙也已关)

报错信息如下:

Exception in thread "main" org.apache.kudu.client.NonRecoverableException: can not complete before timeout: KuduRpc(method=CreateTable, tablet=null, attempt=2, DeadlineTracker(timeout=30000, elapsed=36330), Traces: [0ms] querying master, [184ms] Sub rpc: ConnectToMaster sending RPC to server master-192.168.189.142:7051, [18307ms] Sub rpc: ConnectToMaster received from server master-192.168.189.142:7051 response Network error: [peer master-192.168.189.142:7051(192.168.189.142:7051)] encountered a read timeout; closing the channel, [18310ms] delaying RPC due to Service unavailable: Master config (192.168.189.142:7051) has no leader. Exceptions received: org.apache.kudu.client.RecoverableException: [peer master-192.168.189.142:7051(192.168.189.142:7051)] encountered a read timeout; closing the channel, [18320ms] querying master, [18320ms] Sub rpc: ConnectToMaster sending RPC to server master-192.168.189.142:7051, [36327ms] Sub rpc: ConnectToMaster received from server master-192.168.189.142:7051 response Network error: [peer master-192.168.189.142:7051(192.168.189.142:7051)] encountered a read timeout; closing the channel, [36327ms] delaying RPC due to Service unavailable: Master config (192.168.189.142:7051) has no leader. Exceptions received: org.apache.kudu.client.RecoverableException: [peer master-192.168.189.142:7051(192.168.189.142:7051)] encountered a read timeout; closing the channel)
	at org.apache.kudu.client.KuduException.transformException(KuduException.java:110)
	at org.apache.kudu.client.KuduClient.joinAndHandleException(KuduClient.java:352)
	at org.apache.kudu.client.KuduClient.createTable(KuduClient.java:96)
	at com.imooc.bigdata.chapter07.KuduAPIApp$.createTable(KuduAPIApp.scala:135)
	at com.imooc.bigdata.chapter07.KuduAPIApp$.main(KuduAPIApp.scala:17)
	at com.imooc.bigdata.chapter07.KuduAPIApp.main(KuduAPIApp.scala)
	Suppressed: org.apache.kudu.client.KuduException$OriginalException: Original asynchronous stack trace
		at org.apache.kudu.client.AsyncKuduClient.tooManyAttemptsOrTimeout(AsyncKuduClient.java:1444)
		at org.apache.kudu.client.AsyncKuduClient.delayedSendRpcToTablet(AsyncKuduClient.java:1725)
		at org.apache.kudu.client.AsyncKuduClient.access$900(AsyncKuduClient.java:254)
		at org.apache.kudu.client.AsyncKuduClient$RetryRpcErrback.call(AsyncKuduClient.java:1102)
		at org.apache.kudu.client.AsyncKuduClient$RetryRpcErrback.call(AsyncKuduClient.java:1092)
		at com.stumbleupon.async.Deferred.doCall(Deferred.java:1280)
		at com.stumbleupon.async.Deferred.runCallbacks(Deferred.java:1259)
		at com.stumbleupon.async.Deferred.callback(Deferred.java:1002)
		at org.apache.kudu.client.ConnectToCluster.incrementCountAndCheckExhausted(ConnectToCluster.java:291)
		at org.apache.kudu.client.ConnectToCluster.access$100(ConnectToCluster.java:49)
		at org.apache.kudu.client.ConnectToCluster$ConnectToMasterErrCB.call(ConnectToCluster.java:365)
		at org.apache.kudu.client.ConnectToCluster$ConnectToMasterErrCB.call(ConnectToCluster.java:354)
		at com.stumbleupon.async.Deferred.doCall(Deferred.java:1280)
		at com.stumbleupon.async.Deferred.runCallbacks(Deferred.java:1259)
		at com.stumbleupon.async.Deferred.handleContinuation(Deferred.java:1315)
		at com.stumbleupon.async.Deferred.doCall(Deferred.java:1286)
		at com.stumbleupon.async.Deferred.runCallbacks(Deferred.java:1259)
		at com.stumbleupon.async.Deferred.callback(Deferred.java:1002)
		at org.apache.kudu.client.KuduRpc.handleCallback(KuduRpc.java:246)
		at org.apache.kudu.client.KuduRpc.errback(KuduRpc.java:300)
		at org.apache.kudu.client.RpcProxy.failOrRetryRpc(RpcProxy.java:388)
		at org.apache.kudu.client.RpcProxy.responseReceived(RpcProxy.java:217)
		at org.apache.kudu.client.RpcProxy.access$000(RpcProxy.java:60)
		at org.apache.kudu.client.RpcProxy$1.call(RpcProxy.java:132)
		at org.apache.kudu.client.RpcProxy$1.call(RpcProxy.java:128)
		at org.apache.kudu.client.Connection.cleanup(Connection.java:715)
		at org.apache.kudu.client.Connection.exceptionCaught(Connection.java:460)
		at org.apache.kudu.shaded.org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:112)
		at org.apache.kudu.client.Connection.handleUpstream(Connection.java:244)
		at org.apache.kudu.shaded.org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
		at org.apache.kudu.shaded.org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
		at org.apache.kudu.shaded.org.jboss.netty.channel.SimpleChannelUpstreamHandler.exceptionCaught(SimpleChannelUpstreamHandler.java:153)
		at org.apache.kudu.shaded.org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:112)
		at org.apache.kudu.shaded.org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
		at org.apache.kudu.shaded.org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
		at org.apache.kudu.shaded.org.jboss.netty.channel.Channels.fireExceptionCaught(Channels.java:536)
		at org.apache.kudu.shaded.org.jboss.netty.handler.timeout.ReadTimeoutHandler.readTimedOut(ReadTimeoutHandler.java:236)
		at org.apache.kudu.shaded.org.jboss.netty.handler.timeout.ReadTimeoutHandler$ReadTimeoutTask$1.run(ReadTimeoutHandler.java:276)
		at org.apache.kudu.shaded.org.jboss.netty.channel.socket.ChannelRunnableWrapper.run(ChannelRunnableWrapper.java:40)
		at org.apache.kudu.shaded.org.jboss.netty.channel.socket.nio.AbstractNioSelector.processTaskQueue(AbstractNioSelector.java:391)
		at org.apache.kudu.shaded.org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:315)
		at org.apache.kudu.shaded.org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89)
		at org.apache.kudu.shaded.org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178)
		at org.apache.kudu.shaded.org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
		at org.apache.kudu.shaded.org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
		at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
		at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
		at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.kudu.client.NoLeaderFoundException: Master config (192.168.189.142:7051) has no leader. Exceptions received: org.apache.kudu.client.RecoverableException: [peer master-192.168.189.142:7051(192.168.189.142:7051)] encountered a read timeout; closing the channel
	at org.apache.kudu.client.ConnectToCluster.incrementCountAndCheckExhausted(ConnectToCluster.java:289)
	at org.apache.kudu.client.ConnectToCluster.access$100(ConnectToCluster.java:49)
	at org.apache.kudu.client.ConnectToCluster$ConnectToMasterErrCB.call(ConnectToCluster.java:365)
	at org.apache.kudu.client.ConnectToCluster$ConnectToMasterErrCB.call(ConnectToCluster.java:354)
	at com.stumbleupon.async.Deferred.doCall(Deferred.java:1280)
	at com.stumbleupon.async.Deferred.runCallbacks(Deferred.java:1259)
	at com.stumbleupon.async.Deferred.handleContinuation(Deferred.java:1315)
	at com.stumbleupon.async.Deferred.doCall(Deferred.java:1286)
	at com.stumbleupon.async.Deferred.runCallbacks(Deferred.java:1259)
	at com.stumbleupon.async.Deferred.callback(Deferred.java:1002)
	at org.apache.kudu.client.KuduRpc.handleCallback(KuduRpc.java:246)
	at org.apache.kudu.client.KuduRpc.errback(KuduRpc.java:300)
	at org.apache.kudu.client.RpcProxy.failOrRetryRpc(RpcProxy.java:388)
	at org.apache.kudu.client.RpcProxy.responseReceived(RpcProxy.java:217)
	at org.apache.kudu.client.RpcProxy.access$000(RpcProxy.java:60)
	at org.apache.kudu.client.RpcProxy$1.call(RpcProxy.java:132)
	at org.apache.kudu.client.RpcProxy$1.call(RpcProxy.java:128)
	at org.apache.kudu.client.Connection.cleanup(Connection.java:715)
	at org.apache.kudu.client.Connection.exceptionCaught(Connection.java:460)
	at org.apache.kudu.shaded.org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:112)
	at org.apache.kudu.client.Connection.handleUpstream(Connection.java:244)
	at org.apache.kudu.shaded.org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
	at org.apache.kudu.shaded.org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
	at org.apache.kudu.shaded.org.jboss.netty.channel.SimpleChannelUpstreamHandler.exceptionCaught(SimpleChannelUpstreamHandler.java:153)
	at org.apache.kudu.shaded.org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:112)
	at org.apache.kudu.shaded.org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
	at org.apache.kudu.shaded.org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
	at org.apache.kudu.shaded.org.jboss.netty.channel.Channels.fireExceptionCaught(Channels.java:536)
	at org.apache.kudu.shaded.org.jboss.netty.handler.timeout.ReadTimeoutHandler.readTimedOut(ReadTimeoutHandler.java:236)
	at org.apache.kudu.shaded.org.jboss.netty.handler.timeout.ReadTimeoutHandler$ReadTimeoutTask$1.run(ReadTimeoutHandler.java:276)
	at org.apache.kudu.shaded.org.jboss.netty.channel.socket.ChannelRunnableWrapper.run(ChannelRunnableWrapper.java:40)
	at org.apache.kudu.shaded.org.jboss.netty.channel.socket.nio.AbstractNioSelector.processTaskQueue(AbstractNioSelector.java:391)
	at org.apache.kudu.shaded.org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:315)
	at org.apache.kudu.shaded.org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89)
	at org.apache.kudu.shaded.org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178)
	at org.apache.kudu.shaded.org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
	at org.apache.kudu.shaded.org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.kudu.client.RecoverableException: [peer master-192.168.189.142:7051(192.168.189.142:7051)] encountered a read timeout; closing the channel
	at org.apache.kudu.client.Connection.exceptionCaught(Connection.java:429)
	... 21 more
Caused by: org.apache.kudu.shaded.org.jboss.netty.handler.timeout.ReadTimeoutException
	at org.apache.kudu.shaded.org.jboss.netty.handler.timeout.ReadTimeoutHandler.<clinit>(ReadTimeoutHandler.java:84)
	at org.apache.kudu.client.Connection$ConnectionPipeline.init(Connection.java:803)
	at org.apache.kudu.client.Connection.<init>(Connection.java:204)
	at org.apache.kudu.client.ConnectionCache.getConnection(ConnectionCache.java:135)
	at org.apache.kudu.client.AsyncKuduClient.newRpcProxy(AsyncKuduClient.java:384)
	at org.apache.kudu.client.AsyncKuduClient.newMasterRpcProxy(AsyncKuduClient.java:408)
	at org.apache.kudu.client.ConnectToCluster.connectToMasters(ConnectToCluster.java:173)
	at org.apache.kudu.client.ConnectToCluster.run(ConnectToCluster.java:156)
	at org.apache.kudu.client.AsyncKuduClient.getMasterTableLocationsPB(AsyncKuduClient.java:1505)
	at org.apache.kudu.client.AsyncKuduClient.locateTablet(AsyncKuduClient.java:1478)
	at org.apache.kudu.client.AsyncKuduClient.sendRpcToTablet(AsyncKuduClient.java:1048)
	at org.apache.kudu.client.AsyncKuduClient.createTable(AsyncKuduClient.java:524)
	at org.apache.kudu.client.KuduClient.createTable(KuduClient.java:95)
	at com.imooc.bigdata.chapter07.KuduAPIApp$.createTable(KuduAPIApp.scala:135)
	at com.imooc.bigdata.chapter07.KuduAPIApp$.main(KuduAPIApp.scala:17)
	at com.imooc.bigdata.chapter07.KuduAPIApp.main(KuduAPIApp.scala)
Disconnected from the target VM, address: '127.0.0.1:64214', transport: 'socket'

KUDU是能在网页上打得开的
图片描述

我的运行代码如下:

package com.imooc.bigdata.chapter07

import java.util

import org.apache.kudu.{ColumnSchema, Schema, Type}
import org.apache.kudu.client._

object KuduAPIApp {



  def main(args: Array[String]): Unit = {
    val KUDU_MASTERS = "192.168.189.142"
    val client: KuduClient = new KuduClient.KuduClientBuilder(KUDU_MASTERS).build()
    val tableName = "ods"

     createTable(client, tableName)

  //  insertRows(client, tableName)

//    deleteTable(client, "ods")
//    deleteTable(client, "province_city_stat")
/*    deleteTable(client, "ods_20181007")
    deleteTable(client, "province_city_stat_20181007")
    deleteTable(client, "app_stat_20181007")
    deleteTable(client, "area_stat_20181007")*/
//    deleteTable(client, "region_stat")
//    deleteTable(client, "app_stat")
//    createTable(client, tableName)

//    query(client, tableName)
//    println("======")
//    alterRow(client, tableName)
//    println(".........")
//    query(client, tableName)

//    val newTableName = "pk_kudu"
//    renameTable(client, tableName, newTableName)

    client.close()
  }


  /**
    * 修改表名
    */
  def renameTable(client: KuduClient, tableName: String, newTableName: String) = {

    val options: AlterTableOptions = new AlterTableOptions()
    options.renameTable(newTableName)
    client.alterTable(tableName, options)
  }
  /**
    * 修改表数据
    */
  def alterRow(client: KuduClient, tableName: String) = {
    val table: KuduTable = client.openTable(tableName)
    val session: KuduSession = client.newSession()

    val update: Update = table.newUpdate()
    val row: PartialRow = update.getRow
    row.addString("word", "pk-10")
    row.addInt("cnt", 8888)
    session.apply(update)
  }

  /**
    * 查询数据
    */
  def query(client: KuduClient, tableName: String) = {
    val table: KuduTable = client.openTable(tableName)

    val scanner: KuduScanner = client.newScannerBuilder(table).build()

    while(scanner.hasMoreRows) {
      val iterator: RowResultIterator = scanner.nextRows()

      while(iterator.hasNext) {
        val result: RowResult = iterator.next()
        println(result.getString("word") + " => " + result.getInt("cnt"))
      }
    }

  }


  /**
    * 删除表
    */
  def deleteTable(client: KuduClient, tableName: String) = {
    client.deleteTable(tableName)
  }

  /**
    * 插入数据
    *
    * 作业:自己找资料进行批量插入
    */
  def insertRows(client: KuduClient, tableName: String) = {
    val table: KuduTable = client.openTable(tableName)  // 根据表名获取kudu的表
    val session: KuduSession = client.newSession() // JPA Hibernate

    for(i<-1 to 10) {
      val insert: Insert = table.newInsert()
      val row: PartialRow = insert.getRow
      row.addString("word",s"pk-$i")
      row.addInt("cnt", 100+i)

      session.apply(insert)
    }

  }



  /**
    * 创建表
    */
  def createTable(client: KuduClient, tableName: String): Unit = {
    import scala.collection.JavaConverters._
    val columns = List(
      new ColumnSchema.ColumnSchemaBuilder("word", Type.STRING).key(true).build(),
      new ColumnSchema.ColumnSchemaBuilder("cnt", Type.INT32).build()
    ).asJava

    val schema = new Schema(columns)

    val options: CreateTableOptions = new CreateTableOptions()
    options.setNumReplicas(1)

    val parcols: util.LinkedList[String] = new util.LinkedList[String]()
    parcols.add("word")
    options.addHashPartitions(parcols,3)

    client.createTable(tableName,schema,options)
  }

}

参考其他慕课问答,master.gflagfile文件也已改成这样了,想问下应该如何解决这个问题呢?

--fromenv=rpc_bind_addresses
--fromenv=log_dir

--fs_wal_dir=/data/kudu/kudu_master_data
--fs_data_dirs=/data/kudu/kudu_master_data
--rpc_authentication=disabled
--rpc_encryption=disabled
--trusted_subnets=0.0.0.0/0

正在回答 回答被采纳积分+3

1回答

Michael_PK 2020-05-05 02:06:15

kudu的两个配置文件同时修改

0 回复 有任何疑惑可以回复我~
  • 大佬,我两个配置文件都修改了,然后在windows的host上也添加了hadoop000 的地址,但我还是没有连上kudu
    回复 有任何疑惑可以回复我~ 2020-05-21 21:28:24
  • 解决了吗
    回复 有任何疑惑可以回复我~ 2020-09-18 08:48:18
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信