首页 > 解决方案 > 添加数据中心现有集群

问题描述

我尝试将 dc 添加到我现有的集群中。我用一个键空间更改了我的 networkTopologie,但新的 DC 像完整副本一样工作。我只更改了一个键空间拓扑,但其他键空间的行转到新的 DC。当我添加一个插入我现有集群的东西时,这些也会进入新的 DC。

当我将新的 DC 添加到我的集群时的其他问题我丢失了我用来连接 cassandra 的超级用户。

我的脚步;

在现有节点上;

  1. 更改cassandra-rackdc.properties为:
dc=datacenter1
rack=rack1
  1. 更改 cassandra.yamlsnitch: GossipingPropertyFileSnitch
  2. 节点滚动重启:nodetool flush && nodetool drain && service cassandra stop
  3. 更新应用程序特定的键空间以仅使用现有 DC 的 NetworkTopology
  4. ALTER KEYSPACE {keyspace} WITH replication = {'class': 'NetworkTopologyStrategy', 'datacenter1': '3'} AND durable_writes = true;

新的数据中心;

  1. 创建新实例并在所有节点上安装 cassandra,不要启动服务
  2. 选择单个节点作为 DC 的种子
  3. 更新cassandra.yaml到所有相同的设置,包括cluster_name等...和优化设置,并将所有种子设置为选定的 DC 种子在选定的种子上将种子设置cassandra.yaml为 datacenter1 中的 1-2 个 IP(现有)
  4. 将 cassandra-rackdc.properties 更改为:
dc=datacenter2
rack=rack1
  1. 在选定的 DC 种子节点上启动服务
  2. 检查nodetool status新节点是否在 cassandra 中正确加入
  3. 每次启动之间间隔 2 分钟以 1×1 启动其他节点

现有集群:

更改键空间拓扑

ALTER KEYSPACE {keyspace} 
  WITH replication = {'class': 'NetworkTopologyStrategy', 
     'datacenter1': '3', 'cassandra': '3'} 
  AND durable_writes = true;

键空间模式;

        system_auth |           True | {'class': 'org.apache.cassandra.locator.NetworkTopologyStrategy', 'datacenter1': '1', 'datacenter2': '1'}
      system_schema |           True |                                                   {'class': 'org.apache.cassandra.locator.LocalStrategy'}
                msg |           True |                       {'class': 'org.apache.cassandra.locator.SimpleStrategy', 'replication_factor': '1'}
              event |           True |                     {'class': 'org.apache.cassandra.locator.NetworkTopologyStrategy', 'datacenter1': '1'}
 system_distributed |           True | {'class': 'org.apache.cassandra.locator.NetworkTopologyStrategy', 'datacenter1': '1', 'datacenter2': '1'}
             system |           True |                                                   {'class': 'org.apache.cassandra.locator.LocalStrategy'}
      system_traces |           True | {'class': 'org.apache.cassandra.locator.NetworkTopologyStrategy', 'datacenter1': '1', 'datacenter2': '1'}
Datacenter: datacenter1

=======================
Status=Up/Down

|/ State=Normal/Leaving/Joining/Moving
--  Address        Load       Tokens       Owns    Host ID    
                           Rack
UN  xxxxxx   230.49 KiB  256          ?       6a31597c-a86f-4e01-8f59-425d4f96f5fd  rack1
UN  yyyyyy   342.55 KiB  256          ?       bdc1eb13-9707-4a5f-83f0-1cbfafbc520f  rack1

Datacenter: datacenter2

=======================
Status=Up/Down

|/ State=Normal/Leaving/Joining/Moving

--  Address        Load       Tokens       Owns    Host ID                               Rack
UN  zzzzzzzz   273.42 KiB  256          ?       cc56b7d5-15b7-4744-91f5-2ae2e6ac3a8e  rack1
UN  tttttttt  281.71 KiB  256          ?       4682ed50-7189-4903-8ed5-7c9bbdb09811  rack1

注意:非系统键空间没有相同的复制设置,有效的所有权信息没有意义

标签: cassandranosqlcassandra-3.0

解决方案


这里有详细的流程介绍,请过关。

TDLR,流程包含以下步骤

  1. 更改所有键空间以使用 NTS,除了具有 LocalStrategy 的键空间
  2. 使用包含其他 DC 种子节点的种子节点配置启动新节点
  3. 更改键空间以添加新的 DC
  4. nodetool rebuild <old_dc_name>在所有新节点上运行
  5. 如果需要,更改客户端以使用新的 DC

推荐阅读