如何将节点添加到mnesia群集?

编程入门 行业动态 更新时间:2024-10-25 06:21:14
本文介绍了如何将节点添加到mnesia群集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我是一个erlang和mnesia newbie ..

I'm an erlang and mnesia newbie..

如何将一个新的disc_only_copies节点添加到已经有模式的mnesia数据库?

How do I add a new disc_only_copies node to an mnesia database that already has a schema?

谢谢

推荐答案

启动新节点( b @节点) erl -sname b -mnesia dir'/ path / to / storage'-s mnesia 。这将启动一个名为 b @ node 的新ram_copies节点。

Start your new node (b@node) erl -sname b -mnesia dir '"/path/to/storage"' -s mnesia. This starts a new ram_copies node called b@node.

在您的原始节点(一个@ node ),在erlang提示符下执行 mnesia:change_config(extra_db_nodes,['b @ node'])。这将导致原始节点将 b 连接到mnesia群集。此时, b @ node 已加入群集,但只有模式的副本。

On your original node (a@node), at the erlang prompt execute mnesia:change_config(extra_db_nodes, ['b@node']). This will cause the original node to connect b to the mnesia cluster. At this point, b@node has joined the cluster but only has a copy of the schema.

新节点 b @ node 能够存储光盘副本,我们需要更改 b @ node 上的模式表类型从 ram_copies 到 disc_copies 。在任何节点上运行 mnesia:change_table_copy_type(schema,'b @ node',disc_copies)。

To make new the node b@node capable of storing disc copies, we need to change the schema table type on b@node from ram_copies to disc_copies. Run mnesia:change_table_copy_type(schema, 'b@node', disc_copies). on any node.

b @ node 此时只有一个模式的副本。要将所有表从 a @ node 复制到 b @ node 并维护表类型,可以运行: p>

b@node only has a copy of the schema at this point. To copy all the tables from a@node to b@node and maintain table types, you can run:

[{Tb, mnesia:add_table_copy(Tb, node(), Type)} || {Tb, [{'a@node', Type}]} <- [{T, mnesia:table_info(T, where_to_commit)} || T <- mnesia:system_info(tables)]].

此命令可能需要一段时间才能执行,因为它将通过网络复制每个表的内容。

This command may take a while to execute as it will copy the contents of each table over the network.

b @ node 现在是 a @ node 。您可以修改该语句 - 在调用 mnesia时,将类型变量替换为 disk_only_copies add_table_copy / 3 以复制表格,但确保它们仅在光盘上。

b@node is now an exact replica of a@node. You could modify that statement - replace the Type variable with disc_only_copies in the call to mnesia:add_table_copy/3 in order to copy the tables but ensure they're on disc only.

mnesia文档解释了如何使用我在这里显示的功能。

The mnesia documentation explains how to use the functions I've shown here.

更多推荐

如何将节点添加到mnesia群集?

本文发布于:2023-11-25 15:54:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1630384.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:节点   如何将   mnesia

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!