如何重命名 Cassandra 中的键空间?
如何通过 cassandra-cli 重命名实时 Cassandra 键空间?以前的版本在 cassandra-cli 中有一个选项(“重命名键空间”)。然而,该选项在最近的版本中已被删除。
How do you rename a live Cassandra keyspace through the cassandra-cli? Previous versions had an option in cassandra-cli ("rename keyspace"). However, that option has been dropped in recent releases.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不再支持重命名键空间(和列族),因为它很容易出现竞争条件。请参阅https://issues.apache.org/jira/browse/CASSANDRA-1585。
Renaming keyspaces (and column families) is no longer supported, since it was prone to race conditions. See https://issues.apache.org/jira/browse/CASSANDRA-1585.
我最近需要在 Cassandra 4 中重命名命名空间。我在这里发现了类似的问题 - 创建 Cassandra 中现有 Keyspace 的副本(使用新名称)。主要思想是“克隆密钥空间并删除旧的而不是重命名”。但提供的答案不适合我的 Cassandra 版本,因为
nodetoolfresh
已弃用。但是,我稍微修改了那里的建议,并设法做到了:主要区别是我将 sstables 复制到带有表“cassandra/data/keyspace_new/table-*”的文件夹中。以下是有关如何使用新名称复制命名空间的简短说明。旧的可以稍后删除。
1 - 将架构从旧键空间导出到文件
2 - 将文件中的键空间名称替换为新键空间
3 - 将架构应用到新键空间(以及密钥空间本身)从文件
按照步骤 (4-7) 对每个节点重复
4 - 清除快照
5 - 从以下位置获取快照旧的键空间
6 - 移动将快照复制到新键空间中的表文件夹(请参见下面的脚本),
因此,clone.sh 脚本:
7 - 重新启动 Cassandra
I recently faced the need to rename a namespace in Cassandra 4. I found a similar question here - Create a duplicate of an existing Keyspace in Cassandra (with a new name). The main idea is a "clone keyspace and delete old instead rename". but the answer provided did not fit my version of Cassandra because
nodetool refresh
is deprecated. However, I slightly modified what was suggested there and I managed to do it: the main difference is that I copied the sstables to the folders with the tables 'cassandra/data/keyspace_new/table-*'.Below is a mini instruction on how to copy a namespace with a new name. The old one can be deleted afterwards.
1 - Export the schema from the old keyspace to a file
2 - Replace the keyspace name in the file to new keyspace
3 - Apply the schema to the new keyspace (and the keyspace itself) from the file
Follow steps (4-7) repeat for each node
4 - Clear snapshots
5 - Take snapshots from the old keyspace
6 - Move the snapshots to the table folders in the new keyspace (see script bellow)
so, clone.sh script:
7 - Restart Cassandra