如何将节点添加到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 $ c的精确副本$ C>。您可以修改该语句 - 在调用
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.