【问题标题】:Dse spark to extract data from cluster and load to another clusterDse spark 从集群中提取数据并加载到另一个集群
【发布时间】:2015-11-07 05:03:05
【问题描述】:

我们有两个 DSE 集群,我们想使用 DSE spark 从 cluster1 中提取数据并进行一些转换并加载到 cluster2 中。

如何实现?

【问题讨论】:

    标签: apache-spark datastax datastax-enterprise


    【解决方案1】:

    您可以使用 DSE spark 从 Cluster1 加载到 Cluster2。 唯一的先决条件是使 keyspace 和 table 已经在 Cluster 2 中,数据将在其中加载。

    对于以下设置:

    源集群

    集群 1:

    键空间:rrtest

    表:rrexample

    目标集群

    第 2 组:

    键空间:测试

    表格:示例

    现在第一步是创建键空间和表。 假设该表具有以下描述(从 cql shell 创建)

    在集群 1 上:

    CREATE TABLE rrtest.rrexample 
    (
        username text PRIMARY KEY,
        password text,
        state text
    )
    

    在集群 2 上:

    CREATE TABLE test.example 
    (
        username text PRIMARY KEY,
        password text,
        state text
    )
    

    迁移到cluster2的Scala代码

    ************ Load from Cluster 1*************
    
    import com.datastax.spark.connector.cql._
    import java.net.InetAddress
    val myrdd = { implicit val src = CassandraConnector(Set(InetAddress.getByName("<ip : host1>"))); sc.cassandraTable("rrtest", "rrexample").select("username", "password", "state") }
    
    ************ Migrate to Cluster 2************
    
    {     implicit val dst = CassandraConnector(Set(InetAddress.getByName("<ip:host2>")));    myrdd.saveToCassandra("test", "example") }
    

    【讨论】:

      猜你喜欢
      • 2022-07-11
      • 1970-01-01
      • 2017-01-31
      • 1970-01-01
      • 2018-06-02
      • 2019-04-04
      • 2011-11-30
      • 2014-06-26
      • 2016-08-10
      相关资源
      最近更新 更多