Srikanth
Srikanth

Reputation: 3

Spark Cassandra connection

When I gave this command:

session.execute("CREATE KEYSPACE java_api WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 3}"); 

I'm getting this error:

**Error while computing token map for keyspace dse_leases with datacenter GraphAnalytics: could not achieve replication factor 3 (found 2 replicas only), check your keyspace replication settings.**

While connecting to Cassandra i gave

public static void main(String[] args) {
    String master = "";
    String host = "";

    if (args.length != 2) {

        System.err.println("Syntax: com.datastax.spark.demo.JavaDemo <Spark Master URL> <Cassandra contact point>");
        master = "local[4]";
        host = "10.118.214.144";
    } else {
        master = args[0];
        host = args[1];
    }

    SparkConf conf = new SparkConf();
    conf.setAppName("Java API demo");
    conf.setMaster(master);
    conf.set("spark.cassandra.connection.host", host);

    SparkCassandraSave app = new SparkCassandraSave(conf);
    app.run();
}

Is there any wrong with this?

Upvotes: 0

Views: 130

Answers (1)

Serge Harnyk
Serge Harnyk

Reputation: 1339

Looks like you has only two Cassandra nodes, but your replication factor is three. There are several approaches.

  1. Add at least one more node.
  2. Set replication factor 2.

Upvotes: 0

Related Questions