Erlang/OTP Forums

Author Message

<  Advanced Erlang/OTP  ~  Mnesia Remote connectivity

rkewlani
Posted: Mon Sep 15, 2008 1:43 pm Reply with quote
User Joined: 10 Sep 2008 Posts: 11
hi all,
I am new to mnesia and I want to keep my database on one machine(server) and want it to use from my client machine(like any other database client server module).
How to do it this in mnesia.
I have not found any documentation regarding accessing remote nodes in erlang when remote node is on the other machine(server).
Is there any method to connect to the other host as in other databases connection("ServerIP:port","username","pwd")??

Please help me..
View user's profile Send private message
Adam
Posted: Mon Sep 15, 2008 2:03 pm Reply with quote
User Joined: 23 Aug 2006 Posts: 71 Location: London
I'm not sure if I understand your question, but here are some possible answers:

1. Mnesia can be distributed, so depending on what you want to do, you might want to take a look at creating a replicated table on the client node. More info in the Mnesia manual. Then you can access the table directly.

2. If you mean "using" as accessing Mnesia from outside Erlang, this is not directly possible. You have to write your own interface for that.

3. Or, lastly, you could just make an RPC call to the onther node like this:
Code:
rpc:call(Node, mnesia, dirty_read, [Table, Key])
Doing it this way you need to have connected your nodes beforehand, for more info on that, go here. If you know that you're just going to read the table you could do it this way, but if you plan to read / write etc you should really create a replicated copy of the table on the current node.

Cheers!
Adam

_________________
Adam
Erlang Training & Consulting
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number
dsmith
Posted: Mon Sep 15, 2008 4:10 pm Reply with quote
User Joined: 08 Aug 2007 Posts: 41 Location: Toronto
Yes, if your "client" and "server" are both Erlang nodes on a trusted LAN, I would suggest using distributed Mnesia. Your client could have a "ram copy" while your server could have a "disk copy" or a "disk only copy". This is more of a peer-to-peer arrangement than client-server. If your client code (on the ram only peer) does more reads than writes, this would provide the best performance.

If your client code is not an Erlang node or is not part of the same Erlang cluster. A UDP or TCP connection should be used passing formatted data (JSON, XML, or "Erlang External Term format").

There was some talk of SQL/ODBC at one time, but I think nothing came of it.


Last edited by dsmith on Wed Sep 17, 2008 11:28 am; edited 1 time in total
View user's profile Send private message
rkewlani
Posted: Wed Sep 17, 2008 6:24 am Reply with quote
User Joined: 10 Sep 2008 Posts: 11
Thanks for replying but I am still not getting how to start the mnesia using the remote node and if I need to make a replica as RAM copy at client in order to perform write operation in database then how is mnesia is sufficient over MYSQL since in mnesia i have to commit the same at both end client RAM copy and on server's Disc copy.
for details:
We start Mnesia as
>mnesia:start().
in this case where to specify the name/address of the server.
similarly we create node in mnesia as
>mnesia:create_schema([node()]).
in this case how to specify the desired name of the node so that it can be accessible from with in the LAN.
View user's profile Send private message
dsmith
Posted: Wed Sep 17, 2008 12:19 pm Reply with quote
User Joined: 08 Aug 2007 Posts: 41 Location: Toronto
Mnesia is not MYSQL. The introduction to the mnesia documentation describes when it is appropriate to use mnesia. There are MYSQL binding for Erlang, so you can use it when more appropriate.

Start reading here for a description of how to use distributed mnesia.
View user's profile Send private message
rkewlani
Posted: Thu Sep 18, 2008 6:21 am Reply with quote
User Joined: 10 Sep 2008 Posts: 11
hi Smith
The explaination u gave me already known to me I know this very well that mnesia is not mysql what is my issue is I have already send u as persoanl msg but I guess it didnt deliver so pasting it at forum as well guide me in the best possible way.


Last edited by rkewlani on Thu Sep 18, 2008 6:48 am; edited 1 time in total
View user's profile Send private message
rkewlani
Posted: Thu Sep 18, 2008 6:46 am Reply with quote
User Joined: 10 Sep 2008 Posts: 11
Hi Smith,
My overall requirement is such that
I need to write a code for key value lookup.
In that I will use yaws as my app-server and mnesia as database back-end for lookup so when ever a requset come at server the erlang classes will call the mnesia database tables and reply with the appropriate value. say kind of dictionary lookup.
In that case my database server can be in distributed mode and so how the client can connect to that database node and perform the operation like insert/delete/update. as we do in normal DB's like MySQL,Oracle. Please help me out I am not getting how to make it possible.
View user's profile Send private message

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum