简体   繁体   English

如何将数据从一个Cassandra数据库迁移到另一个数据库?

[英]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.

相关问题 如何将数据从旧模式数据库迁移到具有不同数据库连接的新模式 - How do I migrate data from my old schema database to New schema with different database connection 如何通过网络将数据从一个HDFS集群迁移到另一个集群? - How can I migrate data from one HDFS cluster to another over the network? 如何将数组列表的数据从一个类迁移到另一个类 - How to migrate the data of my arraylist from one class to another class 如何在JavaFx中将数据从一个场景传输到另一个场景? - How do I transfer data from one scene to another in JavaFx? 我如何将数据从一个Couchbase服务器(localhost)迁移到另一台服务器(34.xx.xxx.xx) - How can i migrate data from one Couchbase server(localhost) to another server(34.xx.xxx.xx) 如何在Android中将数据从一项活动转移到另一项活动? - How do I transfer data from one activity to another in Android? 如何将一种方法从一个 class 迁移到另一个? (安卓、Java) - How to migrate one method from one class to another? (Android, Java) 如何从Apache Cassandra 2.0.3迁移到Apache Cassandra 3.11 - How to migrate from apache cassandra 2.0.3 to apache cassandra 3.11 使用for循环从html中提取数据后,如何逐个插入数据库? - After extracting data from html using a for loop, how do I insert one by one into a database? 如何将选择性数据从一个数据库复制到另一个数据库(ORACLE) - How to copy selective data from one database to another (ORACLE)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM