[erlang-questions] beginner: how: mnesia dir using slave:start()

Jonathan Grot <>
Sat Oct 27 18:25:17 CEST 2007


Hello all,

I am trying to set the mnesia directory on a slave node in a way similar to the method suggested by the mnesia manual page:

Quoting the manual:
E = " -env DISPLAY " ++ net_adm:localhost() ++ ":0 ",
Arg = "-mnesia_dir " ++ M ++ " -pa " ++ Dir ++ E,
slave:start(H, Name, Arg).

The slave node gets launched as if I didn't specify a directory;  i.e. it creates a directory in the CWD.  I also tried a few alternatives with no success.

As a workaround, I wrote a shell script to launch the remote node using ssh.  This is okay, but I would like the option of using the slave module.  Any remedies?

Thanks!


Here is my test program:
=============================================
-module(test_mnesia2).
-export([run/1]).

run(Which)->
    % Report local mnesia directory
    LocalMdir = mnesia:system_info(directory),
    io:format("-----------------LOCAL MDIR--------------------~n~p~n",[LocalMdir]),

    % Choose launch method
    case Which of
    1 ->
        % Method suggested by mnesia manual
        slave:start(christina,b,"-mnesia_dir /tmp/MDB");
    2 ->
        % Try to launch like on command line
        slave:start(christina,b,"-mnesia dir /tmp/MDB");
    3 ->
        % Try again to launch like on command line
        slave:start(christina,b,"-mnesia dir \"/tmp/MDB\"")
    end,
    
    % Report remote mnesia directory
    RemoteMdir = rpc:call(,mnesia,system_info,[directory]),
    io:format("-----------------REMOTE MDIR-------------------~n~p~n",[RemoteMdir]),

    % Kill remote node
    slave:stop(),

    io:format("-----------------------------------------------~n").
=============================================

I launch the local shell with:
> erl -sname a -mnesia dir '"/tmp/MDB"'

And run my three cases:

()80> test_mnesia2:run(1).
-----------------LOCAL MDIR--------------------
"/tmp/MDB"
-----------------REMOTE MDIR-------------------
"/raid1/jgrot/erlang/"
-----------------------------------------------
ok



()81> test_mnesia2:run(2).
-----------------LOCAL MDIR--------------------
"/tmp/MDB"
-----------------REMOTE MDIR-------------------
{badrpc,{'EXIT',{aborted,{aborted,{application_load_error,
                                      {bad_environment_value,"/tmp/MDB"}}}}}}

=ERROR REPORT==== 27-Oct-2007::12:05:22 ===
application_controller: syntax error before: '/': /tmp/MDB
-----------------------------------------------
ok



()82> test_mnesia2:run(3).
-----------------LOCAL MDIR--------------------
"/tmp/MDB"
-----------------REMOTE MDIR-------------------
{badrpc,{'EXIT',{aborted,{aborted,{application_load_error,
                                      {bad_environment_value,"/tmp/MDB"}}}}}}

=ERROR REPORT==== 27-Oct-2007::12:05:25 ===
application_controller: syntax error before: '/': /tmp/MDB
-----------------------------------------------
ok



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the erlang-questions mailing list