[erlang-questions] Question about slave:start()

Mihai Balea <>
Mon Mar 29 05:29:13 CEST 2010


On Mar 28, 2010, at 10:00 PM, Ben Lackey wrote:

> Hi,
> 
> I'm trying to use the slave:start() function.  I've tried on both my windows box and a 64bit build of erlang on OpenSUSE 11 with no luck.
> 
> For instance, my windows box is called columbia.  Here's a sample session:
> 
> C:\Windows\system32>erl
> Eshell V5.7.5  (abort with ^G)
> 1> slave:start(columbia).
> ** exception exit: not_alive
>   in function  slave:start/5
> 2> slave:start(localhost).
> ** exception exit: not_alive
>   in function  slave:start/5
> 3> slave:start(columbia, foo).
> ** exception exit: not_alive
>   in function  slave:start/5
> 4> slave:start(columbia, foo).
> 
> Any idea what I'm doing wrong with the host?  From the doc it looks like it should be an atom, so I'm guessing this is what I ought to do.  Likewise, how do I specify the node name?

Maybe this sample session will help you:

cartman:~ mihai$ erl -rsh ssh -sname foo -setcookie mycookie
Erlang R13B04 (erts-5.7.5) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.7.5  (abort with ^G)
()1> slave:start_link(cartman, bar, "-setcookie mycookie"). 
{}
()2> nodes().
[]
()3> node().

()4> 

Here I'm starting a node named foo with cookie "mycookie". Then I use slave:start_link to launch another node named bar on the same machine, with the same cookie.

Starting slave nodes is a finicky operation, you need to make sure you jump through the appropriate hoops:
- make sure you are allowed to execute commands on the remote host. Not so much of a problem if you're running on the same host
- by default, the erlang vm will try to use rsh to run remote commands, you might want to override that when you start it. I'm using ssh in my example
- both master and slave VMs need to be "alive" (have assigned node names) and need to have the same cookies 

Hope this helps,

Mihai


More information about the erlang-questions mailing list