我用分布式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]$
行动......一切都挂起。应用程序未在另一个节点重新启动。
其实,当我写这篇文章的时候,我已经意识到有时候一切都好,有时候我有问题。
任何想法,虽然在恢复“主”节点时可能会出现问题并再次发生死机?
不错的问题:很多选票,但没有答案:) –