【问题标题】:Erlang: Cannot start slave - {error,timeout}Erlang:无法启动奴隶 - {错误,超时}
【发布时间】:2012-06-03 12:04:18
【问题描述】:

我目前正在尝试设置分布式 Tsung 负载测试 使用 Erlang 从属功能的环境,但是我有 未能成功让控制器节点启动从属节点 节点。例如

(musicglue@load1)1> net:ping(musicglue@load2).
pong
(musicglue@load1)2> slave:start(load2,musicglue,"-setcookie tom").
{error,timeout}

背景

我的环境:

控制器 - 主机名:load1,用户:musicglue,Ubuntu 10.04 LTS, 从源代码编译的 Erlang R15B01 从站 - 主机名:load2,用户:musicglue,Ubuntu 10.04 LTS,Erlang R15B01 源代码编译 防火墙已禁用 未安装 SELinux

有效的方法:

  • 我可以通过 SSH 从 load1 到 load2,反之亦然
  • 我可以在 load1 和 load2 上启动一个 erl 会话
  • 我可以在 load2 上从 load1 启动一个 erl 会话; ssh load2 错误
  • 我可以使用 erl 会话从 load1 成功 ping load2 两个节点上的相同 cookie。

Ping 输出:

musicglue@load1:~$ erl -rsh ssh -sname musicglue -setcookie tom
Erlang R15B01 (erts-5.9.1) [source] [64-bit] [smp:4:4] [async-threads:
0] [hipe] [kernel-poll:false]
Eshell V5.9.1  (abort with ^G)
(musicglue@load1)1> net:ping(musicglue@load2).
pong

问题

尝试从 load1 启动从属会话时出现我的问题 加载2:

musicglue@load1:~$ erl -rsh ssh -sname musicglue -setcookie tom
Erlang R15B01 (erts-5.9.1) [source] [64-bit] [smp:4:4] [async-threads:
0] [hipe] [kernel-poll:false]

Eshell V5.9.1  (abort with ^G)
(musicglue@load1)1> net:ping(musicglue@load2).
pong
(musicglue@load1)2> slave:start(load2,musicglue,"-setcookie
tom").
{error,timeout}

这是我在运行 slave:start 命令时从 epmd 得到的输出:

epmd: Thu May 24 10:01:57 2012: Non-local peer connected
epmd: Thu May 24 10:01:57 2012: opening connection on file descriptor
4
epmd: Thu May 24 10:01:57 2012: got 12 bytes
***** 00000000  00 0a 7a 6d 75 73 69 63 67 6c 75 65
|..zmusicglue|
epmd: Thu May 24 10:01:57 2012: ** got PORT2_REQ
epmd: Thu May 24 10:01:57 2012: got 2 bytes
***** 00000000  77 01                                             |w.|
epmd: Thu May 24 10:01:57 2012: ** sent PORT2_RESP (error) for
"musicglue"
epmd: Thu May 24 10:01:57 2012: closing connection on file descriptor
4
epmd: Thu May 24 10:01:57 2012: Local peer connected
epmd: Thu May 24 10:01:57 2012: opening connection on file descriptor
4
epmd: Thu May 24 10:01:57 2012: got 24 bytes
***** 00000000  00 16 78 ca d6 4d 00 00  05 00 05 00 09 6d 75 73
|..x..M.......mus|
***** 00000010  69 63 67 6c 75 65 00 00                           |
icglue..|
epmd: Thu May 24 10:01:57 2012: ** got ALIVE2_REQ
epmd: Thu May 24 10:01:57 2012: registering 'musicglue:1', port 51926
epmd: Thu May 24 10:01:57 2012: type 77 proto 0 highvsn 5 lowvsn 5
epmd: Thu May 24 10:01:57 2012: got 4 bytes
***** 00000000  79 00 00 01                                       |
y...|
epmd: Thu May 24 10:01:57 2012: ** sent ALIVE2_RESP for "musicglue"
epmd: Thu May 24 10:01:57 2012: unregistering 'musicglue:1', port
51926
epmd: Thu May 24 10:01:57 2012: closing connection on file descriptor
4

任何人的帮助或建议将不胜感激,

非常感谢

编辑

我还应该提到,我可以看到 load2 成功确认了 ssh 连接,但随后立即断开连接:

May 30 13:49:27 load2 sshd[16169]: Accepted publickey for musicglue from 173.45.236.182 port 51843 ssh2
May 30 13:49:27 load2 sshd[16171]: Received disconnect from 173.45.236.182: 11: disconnected by user

为了响应下面的 cmets,我还尝试使用不同的从属节点名称来启动从属:

musicglue@load1:~$ erl -rsh ssh -sname musicglue -setcookie tom
Erlang R15B01 (erts-5.9.1) [source] [64-bit] [smp:4:4] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.9.1  (abort with ^G)
(musicglue@load1)1> slave:start(load2,bar,"-setcookie tom").
{error,timeout}

对于控制器:

musicglue@load1:~$ erl -rsh ssh -sname foo -setcookie tom
Erlang R15B01 (erts-5.9.1) [source] [64-bit] [smp:4:4] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.9.1  (abort with ^G)
(foo@load1)1> slave:start(load2,musicglue,"-setcookie tom").
{error,timeout}

对于两者:

musicglue@load1:~$ erl -rsh ssh -sname foo -setcookie tom
Erlang R15B01 (erts-5.9.1) [source] [64-bit] [smp:4:4] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.9.1  (abort with ^G)
(foo@load1)1> slave:start(load2,bar,"-setcookie tom").
{error,timeout}

但是没有用

解决方案

原来我的问题是我的从设备无法通过 SSH 连接到控制器,因此无法响应任何命令。

修复两个节点之间的通信端口后,每个人都工作得很好。

【问题讨论】:

  • 我认为这是因为您正试图在 load2 上启动一个新的从属节点,其名称与现有节点相同,musicglue。你的名字在一台机器上必须是唯一的。
  • 谢谢@rvirding。我尝试了不同节点名称的组合(请参阅编辑后的帖子),但仍然没有运气。我是否误解了您的评论?
  • @rvirding 认为您可能有兴趣知道在解决我的问题(如上所述)之后,我能够在控制器和从属设备上使用相同的名称
  • 你到底是怎么固定通讯端口的,请帮忙
  • @TomMaguire 你是如何解决沟通问题的?

标签: erlang slave tsung


【解决方案1】:

通过 Google 找到此问题的人的替代答案。如果您尝试在单独的机器上启动服务,那么您的控制器节点名称必须解析。

例如,我遇到了超时:

> node().
someName@host.domain.com
> slave:start('192.168.122.196',bar,"-setcookie cookie").
{error,timeout}

通过使用明确的域名启动我的 erlang 实例:

erl -name someName@192.168.1.5 -setcookie cookie
> slave:start('192.168.122.196',bar,"-setcookie cookie").

这个命令现在成功了。

【讨论】:

    【解决方案2】:

    尝试通过在 PATH 的某处创建这样的 shell 脚本来记录通过 SSH 发生的事情:

    #!/bin/sh
    
    echo "$0" "$@" > /tmp/my-ssh.log
    ssh -v "$@"  2>&1 | tee -a /tmp/my-ssh.log
    

    称它为my-ssh,以erl -rsh my-ssh 启动Erlang,然后检查/tmp/my-ssh.log 中的内容。这应该可以解决这个问题......

    【讨论】:

    • 感谢@legoscia,这是一个非常有用的小脚本。我将来肯定会使用它!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多