[英]How do I migrate data from one Cassandra database to another?
I have two Cassandra databases in two different hosts. 我在两个不同的主机中有两个Cassandra数据库。 Both have tables with the exact same definition.
两者都有具有完全相同定义的表。 How do I migrate data from one to the other?
如何将数据从一个迁移到另一个?
SparkConf sparkConf = new SparkConf().setAppName(App.APP_NAME)
.set("spark.cassandra.connection.host", App.CASSANDRA_HOST)
.set("spark.cassandra.auth.username", "user")
.set("spark.cassandra.auth.password", "pass")
.set("spark.cleaner.ttl", "3600");
SparkContext sparkContext = new SparkContext(sparkConf);
JavaRDD<EventLog> logs = javaFunctions(sparkContext)
.cassandraTable("xyz", "event_log", mapRowTo(EventLog.class));
javaFunctions(logs).writerBuilder("xyz", "event_log", mapToRow(EventLog.class)).saveToCassandra();
sparkContext.stop();
In my Java code, I have read from the original DB and want to use the writerBuilder
to write it into another DB. 在我的Java代码中,我已经阅读了原始数据库,并希望使用
writerBuilder
将其写入另一个数据库。 Where do I put the second DB's config and how do I write it there? 如何将第二个数据库的配置放在哪里,如何在其中写入它?
From the docs , there is a method 从文档中 ,有一种方法
def withConnector(connector: CassandraConnector): WriterBuilder
Which you can call to pass in a different CassandraConnector object with the destination cluster information. 您可以调用该方法来传递具有目标群集信息的其他CassandraConnector对象。 This returns a new
WriterBuilder
which you would call saveToCassandra
on. 这将返回一个新的
WriterBuilder
,您将在其上调用saveToCassandra
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.