当前位置: 首页 > 知识库问答 >
问题:

无法在spark-cassandra-connector中更改身份验证

公子昂
2023-03-14
val csc = new CassandraSQLContext(SparkConnection._sc)

csc.setConf(s"${cluster}/spark.cassandra.connection.host", host)
csc.setConf(s"${cluster}/spark.cassandra.connection.port", port)
csc.setConf(s"${cluster}/spark.cassandra.auth.username", username)
csc.setConf(s"${cluster}/spark.cassandra.auth.password", password)

csc.read.format("org.apache.spark.sql.cassandra")
                  .options(Map("cluster" -> cluster, "keyspace" -> keySpace, "table" -> table))
                  .load()
Exception in thread "Thread-10" java.io.IOException: Failed to open native connection to Cassandra at {192.168.1.17}:9042
    at com.datastax.spark.connector.cql.CassandraConnector$.com$datastax$spark$connector$cql$CassandraConnector$$createSession(CassandraConnector.scala:162)
    at com.datastax.spark.connector.cql.CassandraConnector$$anonfun$2.apply(CassandraConnector.scala:148)
    at com.datastax.spark.connector.cql.CassandraConnector$$anonfun$2.apply(CassandraConnector.scala:148)
    at com.datastax.spark.connector.cql.RefCountedCache.createNewValueAndKeys(RefCountedCache.scala:31)
    at com.datastax.spark.connector.cql.RefCountedCache.acquire(RefCountedCache.scala:56)
    at com.datastax.spark.connector.cql.CassandraConnector.openSession(CassandraConnector.scala:81)
    at com.datastax.spark.connector.cql.CassandraConnector.withSessionDo(CassandraConnector.scala:109)
    at com.datastax.spark.connector.rdd.partitioner.CassandraRDDPartitioner$.getTokenFactory(CassandraRDDPartitioner.scala:184)
    at org.apache.spark.sql.cassandra.CassandraSourceRelation$.apply(CassandraSourceRelation.scala:267)
    at org.apache.spark.sql.cassandra.DefaultSource.createRelation(DefaultSource.scala:57)
    at org.apache.spark.sql.execution.datasources.ResolvedDataSource$.apply(ResolvedDataSource.scala:158)
    at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:119)
    at com.bdbizviz.pa.spark.util.ServiceUtil$.readData(ServiceUtil.scala:97)
    at com.bdbizviz.pa.spark.services.SparkServices$$anon$1.run(SparkServices.scala:114)
    at java.lang.Thread.run(Thread.java:745)
Caused by: com.datastax.driver.core.exceptions.AuthenticationException: Authentication error on host /192.168.1.17:9042: Host /192.168.1.17:9042 requires authentication, but no authenticator found in Cluster configuration
    at com.datastax.driver.core.AuthProvider$1.newAuthenticator(AuthProvider.java:40)
    at com.datastax.driver.core.Connection$5.apply(Connection.java:250)
    at com.datastax.driver.core.Connection$5.apply(Connection.java:234)
    at com.google.common.util.concurrent.Futures$ChainingListenableFuture.run(Futures.java:861)
    at com.google.common.util.concurrent.MoreExecutors$SameThreadExecutorService.execute(MoreExecutors.java:297)
    at com.google.common.util.concurrent.ExecutionList.executeListener(ExecutionList.java:156)
    at com.google.common.util.concurrent.ExecutionList.execute(ExecutionList.java:145)
    at com.google.common.util.concurrent.AbstractFuture.set(AbstractFuture.java:185)
    at com.datastax.driver.core.Connection$Future.onSet(Connection.java:1174)
    at com.datastax.driver.core.Connection$Dispatcher.channelRead0(Connection.java:1005)
    at com.datastax.driver.core.Connection$Dispatcher.channelRead0(Connection.java:928)
    at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
    at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:266)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
    at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:244)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846)
    at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:831)
    at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:346)
    at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:254)
    at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:111)
    ... 1 more

共有1个答案

曹沛
2023-03-14

配置键还需要包括键空间。它们应该看起来像:

${cluster}:${keyspace}/spark.cassandra.connection.host

等等。

如果您查看第二个链接,这是setcassandraconf函数将内容转换成的内容。

 类似资料:
  • 我正在尝试使用java类来映射cassandra表以触发rdd,为此我面临一个问题,即cassandra无法创建查询来获取数据。 根据这个链接https://github.com/datastax/spark-cassandra-connector/blob/master/doc/6_advanced_mapper.md,类必须是可序列化的,并且至少对要映射的表的主键列具有“getter”和“se

  • 我在cassandra中有一个表,其中A(String)和B(int)是partiton键,我正在用spark sql编写sql查询 在解释计划中,它似乎是在执行批扫描,而不是在分区键上直接联接 Cassandra筛选器:[[“A”在(?,?,?,?),D],[“B”在(?,?,?,?,?,?,?,?,?),D]] 请求列:[A、B...] 另外,在文档中https://github.com/da

  • 是否可以将Spark cassandra connector Java API与Spark 2.0+一起使用? 我看到spark-cassandra-connector-java2.11的最新版本是1.6.0-M1。 有人知道连接器的Java API的未来吗? 沙伊

  • cluster=hfactory.getOrCreateCluster(“test cluster”,“localhost:9160”,凭据); 但不幸的是,它给了我一个错误: HFactory类型中的方法getOrCreateCluster(String,CassandraHostConfigurator,Map)不适用于参数(String,String,Map)

  • 如何为版本设置以下属性: 本质上,我想设置它,以便应该有0个连接到我的远程dc的客户端,也应该有0个读/写。一切都应该是我正在磨合的DC本地的。 将设置为本地DC是否会达到相同的效果?

  • 我正在使用DataStax驱动程序连接到Cassandra节点。下面是连接器的代码。 验证器:PasswordAuthenticator 调用connect方法时,显示以下错误: 主机LocalHost/127.0.0.1:9042上的身份验证错误:主机LocalHost/127.0.0.1:9042需要身份验证,但在群集配置中找不到身份验证器 编辑:异常堆栈位于