cassandra - 添加数据中心现有集群
问题描述
我尝试将 dc 添加到我现有的集群中。我用一个键空间更改了我的 networkTopologie,但新的 DC 像完整副本一样工作。我只更改了一个键空间拓扑,但其他键空间的行转到新的 DC。当我添加一个插入我现有集群的东西时,这些也会进入新的 DC。
当我将新的 DC 添加到我的集群时的其他问题我丢失了我用来连接 cassandra 的超级用户。
我的脚步;
在现有节点上;
- 更改
cassandra-rackdc.properties
为:
dc=datacenter1
rack=rack1
- 更改 cassandra.yaml
snitch: GossipingPropertyFileSnitch
- 节点滚动重启:
nodetool flush && nodetool drain && service cassandra stop
- 更新应用程序特定的键空间以仅使用现有 DC 的 NetworkTopology
ALTER KEYSPACE {keyspace} WITH replication = {'class': 'NetworkTopologyStrategy', 'datacenter1': '3'} AND durable_writes = true;
新的数据中心;
- 创建新实例并在所有节点上安装 cassandra,不要启动服务
- 选择单个节点作为 DC 的种子
- 更新
cassandra.yaml
到所有相同的设置,包括cluster_name
等...和优化设置,并将所有种子设置为选定的 DC 种子在选定的种子上将种子设置cassandra.yaml
为 datacenter1 中的 1-2 个 IP(现有) - 将 cassandra-rackdc.properties 更改为:
dc=datacenter2
rack=rack1
- 在选定的 DC 种子节点上启动服务
- 检查
nodetool status
新节点是否在 cassandra 中正确加入 - 每次启动之间间隔 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
注意:非系统键空间没有相同的复制设置,有效的所有权信息没有意义
解决方案
这里有详细的流程介绍,请过关。
TDLR,流程包含以下步骤
- 更改所有键空间以使用 NTS,除了具有 LocalStrategy 的键空间
- 使用包含其他 DC 种子节点的种子节点配置启动新节点
- 更改键空间以添加新的 DC
nodetool rebuild <old_dc_name>
在所有新节点上运行- 如果需要,更改客户端以使用新的 DC
推荐阅读
- loopback - 删除“id”字段作为默认排序选项
- firebase - 调试实时应用程序的实时数据库安全规则
- excel - 仅在粘贴到 Excel 时粘贴值
- java - keyExists 无法解析为变量 - Java
- biztalk - BizTalk 中同一终结点上收到的两方的路由消息
- android - 阻止 Android Studio Gradle 构建使用互联网数据的方法
- elasticsearch - 如何在没有偏移的情况下对 Elasticsearch 中的嵌套对象进行分页?
- excel - 在 Excel 工作表中搜索另一个工作表中的关键字列表
- java - 由于无法解析端点而导致的 Apache camel cron 错误:cron
- php - 不能在 Laravel 中使用 Illuminate\\Http\\JsonResponse 类型的对象作为数组