簡體   English   中英

如何運行使用 Rebar 分發的應用程序

[英]How to run an application distributed using Rebar

所以我有一個我想在兩個節點(一個主節點和一個故障轉移)上運行的應用程序。

我為每個節點有 2 個配置文件。 現在我正在使用以下兩個節點上運行我的應用程序:

rebar3 shell --sname a --config a 
rebar3 shell --sname b --config b

問題是應用程序在兩個節點上都啟動,因為我想在我發出rebar命令時它們沒有預先連接。

配置文件

    {kernel,[{distributed,[{ex_banking,['a@AdrianB-LAPTOP','b@Adrian-LAPTOP']}]},
             {sync_nodes_timeout,3000}]},
    {ex_banking,[{port,3000}]}].
    {kernel,[{distributed,[{ex_banking,['a@AdrianB-LAPTOP','b@Adrian-LAPTOP']}]},
             {sync_nodes_mandatory,['a@AdrianB-LAPTOP'},
             {sync_nodes_timeout,3000}]},
    {ex_banking,[{port,3000}]}].

使用rebar shell時/之后連接節點的策略是什么? 有什么方法可以創建腳本之類的嗎?

我只想連接節點,但只有主節點從應用程序啟動開始,而第二個節點在第一個崩潰時啟動。

要連接兩個或多個節點,您還需要為每個節點設置相同的 cookies。 然后通過net_adm:ping/1 ping 這些節點。 這是示例(預計終端將同時啟動):

1號航站樓:

$ ./rebar3 shell --sname a --setcookie test
Erlang/OTP 24 [erts-12.1.5] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]

Eshell V12.1.5  (abort with ^G)
(a@pc)1> nodes().
[]

2號航站樓:

$ ./rebar3 shell --sname b --setcookie test
Erlang/OTP 24 [erts-12.1.5] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]

Eshell V12.1.5  (abort with ^G)
(b@pc)1> nodes().
[]

如您所見,當您運行它時 - 我們沒有任何節點。 現在讓我們嘗試使用net_adm:ping/1來連接它們。 1號航站樓:

$ ./rebar3 shell --sname a --setcookie test
Erlang/OTP 24 [erts-12.1.5] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]

Eshell V12.1.5  (abort with ^G)
(a@pc)1> nodes().
[]
(a@pc)2> net_adm:ping('b@pc').
pong
(a@pc)3> nodes().
[b@pc]

2號航站樓:

$ ./rebar3 shell --sname b --setcookie test
Erlang/OTP 24 [erts-12.1.5] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]

Eshell V12.1.5  (abort with ^G)
(b@pc)1> nodes().
[a@pc]

另外,我想您可以加入https://erlangforums.com/ - 在 Erlang 社區論壇中,您可以足夠快地找到與 Erlang/OTP 相關的任何問題的答案。 PS 您也可以通過vm.args文件設置名稱和 cookie。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM