The JCL for Erlang debugging

Source: Internet
Author: User
Tags rabbitmq

Job control mode (JCL), in which jobs can be started, stopped, detached or connected. The current job can communicate with the shell.

With JCL, we can remotely access an Erlang node to access control

Communication between Erlang nodes requires mutual trust, and mutual trust is done with cookies, so we need to get the other cookie to access the other nodes.

First we have a running Erlang node like this [email protected],ps process when it was not found using Set_cookie, you can use Rabbitmqctl eval "Erlang:get_cookie ()." To get, because the display setting, so the result is a random value.

[Email protected]:~$ sudo ps-ef |grep rab
RABBITMQ 1598 1558 0 06:19? 00:00:22/usr/lib/erlang/erts-5.10.4/bin/beam.smp-w w-k true-a30-p 1048576---root/usr/lib/erlang-progname erl--- HOME/VAR/LIB/RABBITMQ---pa/usr/lib/rabbitmq/lib/rabbitmq_server-3.2.4/sbin/. /ebin-noshell-noinput-s Rabbit boot-sname [email protected]-boot Start_sasl-kernel inet_default_connect_options [{No Delay,true}]-SASL errlog_type error-sasl sasl_error_logger false-rabbit error_logger {file, "/var/log/rabbitmq/[email Protected] "}-rabbit sasl_error_logger {file,"/var/log/rabbitmq/[email protected] "}-rabbit enabled_plugins_file"/ Etc/rabbitmq/enabled_plugins "-rabbit plugins_dir"/usr/lib/rabbitmq/lib/rabbitmq_server-3.2.4/sbin/. /plugins "-rabbit Plugins_expand_dir"/var/lib/rabbitmq/mnesia/[email protected] "-os_mon start_cpu_sup False-os_mon Start_disksup False-os_mon start_memsup false-mnesia dir "/var/lib/rabbitmq/mnesia/[email protected]"

[Email protected]:~$ sudo rabbitmqctl eval "Erlang:get_cookie ()."
' Gekqfelmyvcurlsdqcyi '
... done.

Then start an Erlang node, set a cookie, and try to ping the node you want to connect to

[Email protected]:~$ erl-sname [email protected]
Erlang r16b03 (erts-5.10.4) [source] [Smp:4:4] [async-threads:10] [Kernel-poll:false]

Eshell V5.10.4 (abort with ^g)
([email protected]) 1> Erlang:set_cookie (node (), Gekqfelmyvcurlsdqcyi).
* 1:variable ' gekqfelmyvcurlsdqcyi ' is unbound
([email protected]) 2> Erlang:set_cookie (node (), ' gekqfelmyvcurlsdqcyi ').
True
([email protected]) 3> net_adm:ping (' [email protected] ').
Pong

Access to a node there are two ways I know, one is using Net_kernel:connect_node (Nodename) and the other is the R command using JCL, where we use the latter

Ctl+g into JCL mode

User Switch Command
-H
c [NN]-connect to Job
I [NN]-interrupt job
K [nn]-kill job
J-list All Jobs
s [Shell]-start local shell
R [node [Shell]]-Start remote shell
Q-quit Erlang
? | H-this message
--R ' [email protected] '%%l connection [email protected]
--J%%job list can see the nodes we are connected to
1 {Shell,start,[init]}
protected {' [email] ', shell,start,[]}
--C 2 percent percent switch to job 2, so that successfully access the [email protected]< /c0>

Eshell V5.10.4 (abort with ^g)
([email protected]) 1>

Then we can query the process call stack, memory usage, long wait for the message process to debug.

Questions:

1. The difference between the node name sname and name

2. When the node is started, the Set_cookie setting cookie does not take effect, and the Erlang:set_cookie (XX, BB) is used after creation. feasible

The JCL for Erlang debugging

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.