在运行时从另一个 Erlang shell 访问 Mnesia 节点

发布于 2024-09-07 11:36:33 字数 238 浏览 8 评论 0原文

从另一个 Erlang shell 访问单个正在运行的 mnesia 节点以仅查看表中的数据的最佳实践是什么?

我尝试打开两个 shell 并将它们指向相同的 mnesia 目录位置,在文档中找到这一点后,我意识到这是一个非常糟糕的主意。

-mnesia dir 目录。存储所有 Mnesia 数据的目录的名称。目录名称对于当前节点必须是唯一的。在任何情况下,两个节点都不能共享同一个 Mnesia 目录。结果是完全不可预测的。

What is the best practice to accessing a single running mnesia node from another Erlang shell to only view data in the tables?

I tried opening two shells and pointing them to the same mnesia directory location which I realized was a very bad idea after finding this in the documentation.

-mnesia dir Directory. The name of the directory where all Mnesia data is stored. The name of the directory must be unique for the current node. Two nodes may, under no circumstances, share the same Mnesia directory. The results are totally unpredictable.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

又怨 2024-09-14 11:37:23

我认为最简单的方法是加入远程 shell。只需使用 -remsh Node 参数启动 erl

$ erl -sname foo
Erlang R13B04 (erts-5.7.5) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.7.5  (abort with ^G)
(foo@hynek-notebook)1> 

另一个终端:

$ erl -sname bar -remsh 'foo@hynek-notebook'
Erlang R13B04 (erts-5.7.5) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.7.5  (abort with ^G)
(foo@hynek-notebook)1> 

另一个选择是使用 erl 强大的作业控制功能(按 ^G< /code>)

$ erl -sname bar
Erlang R13B04 (erts-5.7.5) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.7.5  (abort with ^G)
(bar@hynek-notebook)1> 
User switch command
 --> h
  c [nn]            - connect to job
  i [nn]            - interrupt job
  k [nn]            - kill job
  j                 - list all jobs
  s [shell]         - start local shell
  r [node [shell]]  - start remote shell
  q        - quit erlang
  ? | h             - this message
 --> r 'foo@hynek-notebook'
 --> j
   1  {shell,start,[init]}
   2* {'foo@hynek-notebook',shell,start,[]}
 --> c 
Eshell V5.7.5  (abort with ^G)
(foo@hynek-notebook)1> 
User switch command
 --> j
   1  {shell,start,[init]}
   2* {'foo@hynek-notebook',shell,start,[]}
 --> c 1

(bar@hynek-notebook)1>

请注意,如果您要切换回现有 shell,则必须按 Enter 才能显示 shell 提示符。

I think that easiest way is joining to remote shell. Just start erl with -remsh Node parameter

$ erl -sname foo
Erlang R13B04 (erts-5.7.5) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.7.5  (abort with ^G)
(foo@hynek-notebook)1> 

Another terminal:

$ erl -sname bar -remsh 'foo@hynek-notebook'
Erlang R13B04 (erts-5.7.5) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.7.5  (abort with ^G)
(foo@hynek-notebook)1> 

Another option is use powerful job control capability of erl (Press ^G)

$ erl -sname bar
Erlang R13B04 (erts-5.7.5) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.7.5  (abort with ^G)
(bar@hynek-notebook)1> 
User switch command
 --> h
  c [nn]            - connect to job
  i [nn]            - interrupt job
  k [nn]            - kill job
  j                 - list all jobs
  s [shell]         - start local shell
  r [node [shell]]  - start remote shell
  q        - quit erlang
  ? | h             - this message
 --> r 'foo@hynek-notebook'
 --> j
   1  {shell,start,[init]}
   2* {'foo@hynek-notebook',shell,start,[]}
 --> c 
Eshell V5.7.5  (abort with ^G)
(foo@hynek-notebook)1> 
User switch command
 --> j
   1  {shell,start,[init]}
   2* {'foo@hynek-notebook',shell,start,[]}
 --> c 1

(bar@hynek-notebook)1>

Note that you have to press Enter to show shell prompt if you are switching back to existing one.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文