如何删除多余的节点
我有一组 erlang 节点,它们通过 Mnesia 的“extra_db_nodes”复制数据...我需要升级硬件和软件,所以当我从一个节点移动到另一个节点时,我必须分离一些节点。
如何删除一个节点并仍然保留插入的数据?
[更新]删除节点与添加节点一样重要。 随着时间的推移,随着集群的增长,它也必须收缩。 如果不是,那么 Mnesia 将忙于尝试向不存在的节点发送数据,从而填满队列并保持网络繁忙。
[最终更新]在仔细阅读 erlang/mnesia 源代码后,我确定不可能完全解除节点关联。 虽然 del_table_copy 删除了表之间的链接,但它是不完整的。 我想结束这个问题,但没有一个密切的描述是足够的。
I have a group of erlang nodes that are replicating their data through Mnesia's "extra_db_nodes"... I need to upgrade hardware and software so I have to detach some nodes as I make my way from node to node.
How does one remove a node and still preserve the data that was inserted?
[update] removing nodes is as important as adding them. Over time as your cluster grows it must also contract. If not then Mnesia is going to be busy trying to send data to nonexistent nodes filling up queues and keeping the network busy.
[final update] after pouring through the erlang/mnesia source code I was able to determine that it is not possible to completely disassociate nodes. While del_table_copy removes the linkage between tables it is incomplete. I would close this question but none of the close descriptions are adequate.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我希望我很久以前就发现了这个: http: //weblambdazero.blogspot.com/2008/08/erlang-tips-and-tricks-mnesia.html
基本上,具有正常运行的集群....
登录到要删除的集群
停止mnesia
登录到集群上的不同节点
删除架构
I wish I had found this a long time ago: http://weblambdazero.blogspot.com/2008/08/erlang-tips-and-tricks-mnesia.html
basically, with a properly functioning cluster....
login to the cluster to be removed
stop mnesia
login to a different node on the cluster
delete the schema
我参加聚会非常晚,但在寻找同一问题的解决方案时在文档中发现了以下信息:
我认为以下内容可能会满足您的要求:
不过,我还没有测试它,因为我的场景略有不同。
I'm extremely late to the party, but came across this info in the doc when looking for a solution to the same problem:
I think the following might do what you desire:
Though, I haven't tested it since my scenario is slightly different.
我当然使用了这种方法来执行此操作(支持 mnesia:del_table_copy/2 使用)。 请参阅下面的removeNode/1:
I've certainly used this method to perform this (supporting the mnesia:del_table_copy/2 use). See removeNode/1 below:
如果您已在要删除的节点以外的节点上复制了表(添加的表副本),那么就已经没问题了 - 只需删除该节点即可。
如果您想稍微整洁一点,可以通过
mnesia:del_table_copy/2
从要首先删除的节点中删除表副本。一般来说,mnesia 会优雅地处理节点丢失并检测节点重新加入(重新启动的节点从继续运行的节点获取新的表副本,未重新启动的节点被检测为网络分区事件)。 Mnesia 不会为已关闭的节点消耗 CPU 或网络流量。 我认为,尽管我没有在源中确认,mnesia 不会重新连接到自动关闭的节点 - 关闭的节点预计会重新启动(mnesia)并重新连接。
mnesia:add_table_copy/3
、mnesia:move_table_copy/3
和mnesia:del_table_copy/2
是您应该查看实时模式管理的函数。extra_db_nodes
参数仅应在初始化新数据库节点时使用 - 一旦新节点拥有架构副本,就不需要extra_db_nodes
参数。If you have replicated the table (added table copies) on nodes other than the one you're removing, then you're already fine - just remove the node.
If you wanted to be slightly tidier you'd delete the table copies from the node you're about to remove first via
mnesia:del_table_copy/2
.Generally, mnesia gracefully handles node loss and detects node rejoin (rebooted nodes obtain new table copies from nodes that kept running, nodes that didn't reboot are detected as a network partition event). Mnesia does not consume CPU or network traffic for nodes that have gone down. I think, though I haven't confirmed it in the source, mnesia won't reconnect to nodes that have gone down automatically - the node that goes down is expected to reboot (mnesia) and reconnect.
mnesia:add_table_copy/3
,mnesia:move_table_copy/3
andmnesia:del_table_copy/2
are the functions you should look at for live schema management.The
extra_db_nodes
parameter should only be used when initialising a new DB node - once a new node has a copy of the schema it doesn't need theextra_db_nodes
parameter.