我用分佈式erlang應用程序支付。Erlang:分佈式應用程序奇怪的行爲
配置和想法摘自:
HTTP:/www.erlang.org/doc/pdf/otp-system-documentation.pdf 9.9。分佈式應用
- 我們有3個節點:N1 @ A2-X201,N2 @ A2-X201,N3 @ A2-X201
- 我們有應用WD是做了一些有益的工作:)
配置文件:
- wd1.config - 第一個節點:
[{kernel, [{distributed,[{wd,5000,['[email protected]',{'[email protected]','[email protected]'}]}]}, {sync_nodes_mandatory,['[email protected]','[email protected]']}, {sync_nodes_timeout,5000} ]} ,{sasl, [ %% All reports go to this file {sasl_error_logger,{file,"/tmp/wd_n1.log"}} ] }].
- wd2.config用於第二:
[{kernel, [{distributed,[{wd,5000,['[email protected]',{'[email protected]','[email protected]'}]}]}, {sync_nodes_mandatory,['[email protected]','[email protected]']}, {sync_nodes_timeout,5000} ] } ,{sasl, [ %% All reports go to this file {sasl_error_logger,{file,"/tmp/wd_n2.log"}} ] }].
- 對於節點n3類似於。
現在,在3個不同的終端開始二郎:
- ERL -sname N1 @ A2-X201 -config WD1 -pa $ WD_EBIN_PATH -boot start_sasl
- ERL -sname N2 @ A2-X201 - 配置WD2 -pa $ WD_EBIN_PATH -boot start_sasl
- ERL -sname N3 @ A2-X201 -config WD3 -pa $ WD_EBIN_PATH -boot start_sasl
開始每個Erlang節點的應用: *應用程序:開始(wd)。
([email protected])1> application:start(wd). =INFO REPORT==== 19-Jun-2011::15:42:51 === wd_plug_server starting... PluginId: 4 Path: "/home/a2/src/erl/data/SIG" FileMask: "(?i)(.*)\\.SIG$" ok
([email protected])1> application:start(wd). ok ([email protected])2>
([email protected])1> application:start(wd). ok ([email protected])2>
目前一切正常。作爲書面二郎山文檔中:應用程序在節點上運行N1 @ A2-X201
現在殺節點N1: 應用程序遷移到N2
([email protected])2> =INFO REPORT==== 19-Jun-2011::15:46:28 === wd_plug_server starting... PluginId: 4 Path: "/home/a2/src/erl/data/SIG" FileMask: "(?i)(.*)\\.SIG$"
繼續我們的遊戲:幹掉節點n2 再一次系統工作正常。我們有我們的節點N3
([email protected])2> =INFO REPORT==== 19-Jun-2011::15:48:18 === wd_plug_server starting... PluginId: 4 Path: "/home/a2/src/erl/data/SIG" FileMask: "(?i)(.*)\\.SIG$"
應用程序現在恢復節點N1和N2。 所以:
Erlang R14B (erts-5.8.1) [source] [smp:4:4] [rq:4] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.8.1 (abort with ^G) ([email protected])1> Eshell V5.8.1 (abort with ^G) ([email protected])1>
節點N1和N2回來了。
貌似現在我必須手動重新啓動應用程序: *讓我們開始吧節點N2第一:
([email protected])1> application:start(wd).
- 看起來它掛...
- 現在在N1重新啓動
([email protected])1> application:start(wd). =INFO REPORT==== 19-Jun-2011::15:55:43 === wd_plug_server starting... PluginId: 4 Path: "/home/a2/src/erl/data/SIG" FileMask: "(?i)(.*)\\.SIG$" ok ([email protected])2>
它的工作原理。和節點N2也已恢復正常:
Eshell V5.8.1 (abort with ^G) ([email protected])1> application:start(wd). ok ([email protected])2>
在節點N3我們看到:
=INFO REPORT==== 19-Jun-2011::15:55:43 === application: wd exited: stopped type: temporary
在一般情況下,一切看起來正常,寫在文檔中,除延遲與啓動應用程序節點n2。
現在殺節點N1一次:
([email protected])2> User switch command --> q [[email protected] releases]$
行動......一切都掛起。應用程序未在另一個節點重新啓動。
其實,當我寫這篇文章的時候,我已經意識到有時候一切都好,有時候我有問題。
任何想法,雖然在恢復「主」節點時可能會出現問題並再次發生死機?
不錯的問題:很多選票,但沒有答案:) –