本文介绍了为什么星火卡桑德拉连接失败,NoHostAvailableException?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有越来越星火卡桑德拉连接器在Scala中工作的问题。

我使用这些版本:


  • 斯卡拉2.10.4

  • 火花核心1.0.2

  • 卡桑德拉 - 节俭2.1.0(我装Cassandra是V2.1.0)

  • 卡桑德拉 - clientutil 2.1.0

  • 卡桑德拉驱动核心2.0.4(推荐用于连接器?)

  • 火花卡桑德拉连接器1.0.0

我可以连接和交谈卡桑德拉(W / O火花),我可以跟星火(W / O卡珊德拉),但连接器给我:

What am I missing? Cassandra is a default install (port 9042 for cql according to cassandra.yaml). I'm trying to connect locally ("local").

My code:

val conf = new SparkConf().setAppName("Simple Application").setMaster("local")
val sc = new SparkContext("local","test",conf)
val rdd = sc.cassandraTable("myks","users")
val rr = rdd.first
println(s"Result: $rr")
解决方案

Local in this context is specifying the Spark master (telling it to run in local mode) and not the Cassandra connection host.

To set the Cassandra Connection host you have to set a different property in the Spark Config

import org.apache.spark._

val conf = new SparkConf(true)
        .set("spark.cassandra.connection.host", "IP Cassandra Is Listening On")
        .set("spark.cassandra.username", "cassandra") //Optional            
        .set("spark.cassandra.password", "cassandra") //Optional

val sc = new SparkContext("spark://Spark Master IP:7077", "test", conf)

https://github.com/datastax/spark-cassandra-connector/blob/master/doc/1_connecting.md

这篇关于为什么星火卡桑德拉连接失败,NoHostAvailableException?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 00:10