Erlang 为什么这些mnesia表的大小在不同的节点上显示不同?

Erlang 为什么这些mnesia表的大小在不同的节点上显示不同?,erlang,elixir,mnesia,Erlang,Elixir,Mnesia,因此,在多节点(2节点)集群中运行mnesia时,可以选择磁盘拷贝,当我登录到服务器并使用ls-l检查目录内容时,我会看到以下mnesia表大小: 节点1: -rw-r--r-- 1 root root 8 Jul 25 20:58 applications.DCD -rw-r--r-- 1 root root 1530 Jul 26 00:25 applications.DCL -rw-r--r-- 1 root root 132 Jul 26 01:10 LATEST.L

因此,在多节点(2节点)集群中运行mnesia时,可以选择磁盘拷贝,当我登录到服务器并使用
ls-l
检查目录内容时,我会看到以下mnesia表大小:

节点1:

-rw-r--r-- 1 root root      8 Jul 25 20:58 applications.DCD
-rw-r--r-- 1 root root   1530 Jul 26 00:25 applications.DCL
-rw-r--r-- 1 root root    132 Jul 26 01:10 LATEST.LOG
-rw-r--r-- 1 root root      8 Jul 25 20:58 table.DCD
-rw-r--r-- 1 root root 237451 Jul 26 00:43 table.DCL
-rw-r--r-- 1 root root      8 Jul 25 20:58 kite_table.DCD
-rw-r--r-- 1 root root  80707 Jul 26 00:43 kite_table.DCL
-rw-r--r-- 1 root root  14730 Jul 26 01:03 schema.DAT
table         : with 64       records occupying 38477    words of mem
kite_table    : with 1        records occupying 13562    words of mem
applications: with 4        records occupying 488      words of mem
schema         : with 9        records occupying 1486     words of mem
节点2:

-rw-r--r-- 1 root root    196 Jul 26 01:13 DECISION_TAB.LOG
-rw-r--r-- 1 root root   1238 Jul 26 01:10 applications.DCD
-rw-r--r-- 1 root root    132 Jul 26 01:13 LATEST.LOG
-rw-r--r-- 1 root root 233483 Jul 26 01:10 table.DCD
-rw-r--r-- 1 root root  80674 Jul 26 01:10 kite_table.DCD
-rw-r--r-- 1 root root  17032 Jul 26 01:09 schema.DAT
table         : with 64       records occupying 38477    words of mem
kite_table    : with 1        records occupying 13562    words of mem
applications: with 4        records occupying 488      words of mem
schema         : with 9        records occupying 1486     words of mem
但是通过调用
:mnesia.info()
提取相同的数据,我看到:

节点1:

-rw-r--r-- 1 root root      8 Jul 25 20:58 applications.DCD
-rw-r--r-- 1 root root   1530 Jul 26 00:25 applications.DCL
-rw-r--r-- 1 root root    132 Jul 26 01:10 LATEST.LOG
-rw-r--r-- 1 root root      8 Jul 25 20:58 table.DCD
-rw-r--r-- 1 root root 237451 Jul 26 00:43 table.DCL
-rw-r--r-- 1 root root      8 Jul 25 20:58 kite_table.DCD
-rw-r--r-- 1 root root  80707 Jul 26 00:43 kite_table.DCL
-rw-r--r-- 1 root root  14730 Jul 26 01:03 schema.DAT
table         : with 64       records occupying 38477    words of mem
kite_table    : with 1        records occupying 13562    words of mem
applications: with 4        records occupying 488      words of mem
schema         : with 9        records occupying 1486     words of mem
节点2:

-rw-r--r-- 1 root root    196 Jul 26 01:13 DECISION_TAB.LOG
-rw-r--r-- 1 root root   1238 Jul 26 01:10 applications.DCD
-rw-r--r-- 1 root root    132 Jul 26 01:13 LATEST.LOG
-rw-r--r-- 1 root root 233483 Jul 26 01:10 table.DCD
-rw-r--r-- 1 root root  80674 Jul 26 01:10 kite_table.DCD
-rw-r--r-- 1 root root  17032 Jul 26 01:09 schema.DAT
table         : with 64       records occupying 38477    words of mem
kite_table    : with 1        records occupying 13562    words of mem
applications: with 4        records occupying 488      words of mem
schema         : with 9        records occupying 1486     words of mem
然后显示数据大小相同且一致。有人能解释这种明显的不一致吗

下面的代码显示了在系统中执行的典型调用:mnesia.create_table/2

opts = [
  {:attributes, [id: nil, data: %{}]},
  {:type, :set},
  {:index, []},
  {:disc_copies, [node() | Node.list([:visible])]}
]

:mnesia.create_table(:kite_table, opts)
我对的读数表明,这可能是正常现象:

启动Mnesia时,将创建一个名为LATEST.LOG的.LOG文件,并 放置在数据库目录中。Mnesia使用此文件记录日志 基于光盘的事务。这包括在上写入的所有事务 表中至少有一条存储类型为光盘拷贝的记录,或 仅光盘拷贝。该文件还包括以下所有操作: 操纵模式本身,例如创建新表。日志 格式可以随Mnesia的不同实现而变化。记忆 日志当前在标准库模块磁盘日志中实现 在内核中

日志文件持续增长,必须定期转储 间隔。“转储日志文件”意味着Mnesia执行所有 日志中列出的操作,并将记录放在 对应的.DAT、.DCD和.DCL数据文件。例如,如果 日志中列出了操作“写入记录{foo,4,elvis,6}”, Mnesia将操作插入到文件foo.DCL中。后来,当记忆丧失时 认为.DCL文件太大,数据被移动到.DCD 文件如果日志很大,转储操作可能会很耗时。 请注意,Mnesia系统在日志转储期间继续运行

默认情况下,Mnesia会在创建100条记录时转储日志 记录在日志中或三分钟后。这是 由两个应用参数控制-mnesia 转储\u日志\u写入\u阈值写入操作和-mnesia 转储\u日志\u时间\u阈值毫秒

我真的希望
info()
的文档会这样说:

从表的RAM副本检索表信息

文件还说:

光盘拷贝。此属性指定表保存在RAM和光盘中的Erlang节点列表。该表的所有更新都是 在实际表格中执行,并记录到光盘…中 在表上执行的事务将附加到日志文件并 写入RAM表


关闭应用程序后,文件大小是什么样子的?我希望它们是等效的。

您能提供创建数据库的代码吗。函数mnesia:create_table的参数将非常有用。使用create_table/2的典型调用更新了@YuriGinsburg,thanksI在我的计算机上启动了两个节点,然后使用
{disc_copies[n1@mymbp2, n2@mymbp2]}
mnesia:create_table()
函数中,我看到了与您相同的东西。谢谢@7stud,两个节点之间的许多文件大小不同。即使最新的.LOG在一个节点上也是232,在另一个节点上也是132。