Erlang 远程 shell 不工作
Erlang remote shell not working
我的 docker 容器 (CentOS) 有一些奇怪的行为。当我通过 SSH 连接到它时,有一个 Erlang VM (api@127.0.0.1) 的 运行ning 实例,我无法使用 -remsh 参数连接到它,但是我可以 ping 它。不过,我的 Erlang 节点 (api@127.0.0.1) 工作正常。
bash-4.2# ./bin/erl -name 'remote@127.0.0.1' -remsh 'api@127.0.0.1'
Eshell V6.1 (abort with ^G)
(remote@127.0.0.1)1> node().
'remote@127.0.0.1'
(remote@127.0.0.1)2> net_adm:ping('api@127.0.0.1').
pong
(remote@127.0.0.1)3> erlang:system_info(system_version).
"Erlang/OTP 17 [erts-6.1] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false]\n"
(remote@127.0.0.1)4> rpc:call('api@127.0.0.1', erlang, node, []).
'api@127.0.0.1'
有 2 个 linux 进程 运行ning - 一个用于实际 VM,另一个用于尝试调用远程 shell
的进程
26 ? Sl 40:46 /home/vcap/app/bin/beam.smp -- -root /home/vcap/app -progname erl -- -home /home/vcap/app/ -- -name api@127.0.0.1 -boot releases/14.2.0299/start -config sys -boot_var PATH lib -noshell
32542 ? Sl+ 0:00 /home/vcap/app/bin/beam.smp -- -root /home/vcap/app -progname erl -- -home /home/vcap/app -- -name remote@127.0.0.1 -remsh api@127.0.0.1
当我将 Erlang 二进制文件复制到主机 (Arch Linux) 和 运行 ./bin/erl 时,我得到了不同的结果:
[jodias@arch tmp]$ ./bin/erl
Erlang/OTP 17 [erts-6.1] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]
Eshell V6.1 (abort with ^G)
1>
请注意,打印了 Erlang 系统版本,但 docker 容器中没有(但是 Erlang 二进制文件完全相同)。
shell 中的 $TERM
是什么?您正在尝试打开远程?当 TERM 不存在或 Erlang 所针对的 ncurses 不知道 TERM 时,会出现问题,从而导致远程 shell 连接静默失败。试试这个:
TERM=xterm ./bin/erl -name 'remote@127.0.0.1' -remsh 'api@127.0.0.1'
我曾经报告过 the problem to Erlang mailing list but no answer came up. Now I see this issue 在 Erlang 问题跟踪器中。请投票选出 OTP 团队 ;)
我的 docker 容器 (CentOS) 有一些奇怪的行为。当我通过 SSH 连接到它时,有一个 Erlang VM (api@127.0.0.1) 的 运行ning 实例,我无法使用 -remsh 参数连接到它,但是我可以 ping 它。不过,我的 Erlang 节点 (api@127.0.0.1) 工作正常。
bash-4.2# ./bin/erl -name 'remote@127.0.0.1' -remsh 'api@127.0.0.1'
Eshell V6.1 (abort with ^G)
(remote@127.0.0.1)1> node().
'remote@127.0.0.1'
(remote@127.0.0.1)2> net_adm:ping('api@127.0.0.1').
pong
(remote@127.0.0.1)3> erlang:system_info(system_version).
"Erlang/OTP 17 [erts-6.1] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false]\n"
(remote@127.0.0.1)4> rpc:call('api@127.0.0.1', erlang, node, []).
'api@127.0.0.1'
有 2 个 linux 进程 运行ning - 一个用于实际 VM,另一个用于尝试调用远程 shell
的进程26 ? Sl 40:46 /home/vcap/app/bin/beam.smp -- -root /home/vcap/app -progname erl -- -home /home/vcap/app/ -- -name api@127.0.0.1 -boot releases/14.2.0299/start -config sys -boot_var PATH lib -noshell
32542 ? Sl+ 0:00 /home/vcap/app/bin/beam.smp -- -root /home/vcap/app -progname erl -- -home /home/vcap/app -- -name remote@127.0.0.1 -remsh api@127.0.0.1
当我将 Erlang 二进制文件复制到主机 (Arch Linux) 和 运行 ./bin/erl 时,我得到了不同的结果:
[jodias@arch tmp]$ ./bin/erl
Erlang/OTP 17 [erts-6.1] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]
Eshell V6.1 (abort with ^G)
1>
请注意,打印了 Erlang 系统版本,但 docker 容器中没有(但是 Erlang 二进制文件完全相同)。
shell 中的 $TERM
是什么?您正在尝试打开远程?当 TERM 不存在或 Erlang 所针对的 ncurses 不知道 TERM 时,会出现问题,从而导致远程 shell 连接静默失败。试试这个:
TERM=xterm ./bin/erl -name 'remote@127.0.0.1' -remsh 'api@127.0.0.1'
我曾经报告过 the problem to Erlang mailing list but no answer came up. Now I see this issue 在 Erlang 问题跟踪器中。请投票选出 OTP 团队 ;)