创建现有ram表的mnesia disk_copies [英] Creating mnesia disk_copies of existing ram table

查看:225
本文介绍了创建现有ram表的mnesia disk_copies的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个完整的mnesia ram_copies-only数据库,但是在向某个节点添加disk_copy表时遇到问题。现在我做:

I have a complete mnesia ram_copies-only database but I am experiencing problems adding a disk_copy table to a node. At the moment I do:


  1. 创建我所有的ram_copy表/节点

  1. Create all my ram_copy tables/nodes

在disk_copy-to-be节点上启动mnesia。

Start mnesia on the disk_copy-to-be node.

一切似乎都按照计划(没有运行时错误),但是当我去pwd()。目录和检查,没有反映我刚刚创建的表的文件。另外当我在节点上调用 mnesia:info()时,没有disk_copy表,只有一个ram_copy模式。

Everything seems to go according to plan (no run-time errors), but when I go to the pwd(). directory and check, there is no file reflecting the table I just created. Also when I call mnesia:info() on the node, there are no disk_copy tables, only a ram_copy schema.

推荐答案

您是否可以检查运行db节点字段是否列出了您已启动的两个节点?
可能是你没有将第二个节点添加到mnesia集群。

Can you check that the field "running db nodes" lists both nodes that you have started ? It could be that you did not add the second node to the mnesia cluster.

所以如果你的第二个节点被称为BNode,那么在第一个节点上将按以下顺序运行这些命令:

So if your second node was called BNode, then on the first node you would run these commands in this order:

1) mnesia:change_config(extra_db_nodes, [BNode]).  
2) mnesia:add_table_copy(table, BNode, disc_copies).

第二:我想你应该创建模式(步骤3),然后再启动mnesia disk_copy-to-be节点(步骤2)。

Second: I think you should be creating the schema (step 3) before you start up mnesia on the disk_copy-to-be node (step 2).

这是我创建所需的模式:

假设你有2节点NodeA和NodeB。

确保在开始之前没有Mnesia目录已存在。

This is what I did to create the schema you require:
Lets assume you have 2 nodes NodeA and NodeB.
Make sure that there is no Mnesia dir already existing before you start this.

%% From NodeA, setup the A node
erl -sname a -setcookie cookie
mnesia:start().
mnesia:create_table(mytable, [{attributes, [field1, field2]}]).

%% From NodeB, setup the B node
erl -sname b -setcookie cookie
net_adm:ping(NodeA).
mnesia:create_schema([node()]).
mnesia:start().

%% From NodeA, Add the NodeB to the mnesia cluster
[BNode | _] = nodes().
mnesia:change_config(extra_db_nodes, [BNode]).

%% From NodeA, add NodeB as a disc copy
mnesia:add_table_copy(mytable, BNode, disc_copies).

这篇关于创建现有ram表的mnesia disk_copies的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆