If a section gets to big and the document gets to big, then you might consider creating a page for that specific topic.
How to run Erlang
...The way we want:
erl +A 1 +Ktrue -boot start_sasl +W w -sname s -setcookie mnesia -pa /usr/lib/erlang/lib/yaws-1.77/ebin -yaws embedded true debug
Mnesia Notes
Mnesia - Use Cases
NOTA: caso ainda nunca tenha sido criada nenhuma BD nos nós, deve usar-se
m1> mnesia:create_schema(['c@dumpfs1' | 'c@dumpfs2']).
para criar um schema partilhado, antes de fazer mnesia:start(). mas depois de os 2 nós já se conhecerem (net:ping).
Caso contrário:
Run mnesia on m1
(goto mnesia parent dir)
m1> cd /servers/dumpFS/MetaData/Mnesia
m1> erl -sname m -setcookie mnesia
m1> mnesia:start().
Run mnesia on m2
m2> (goto mnesia parent dir)
m2> erl -sname m -setcookie mnesia
m2> mnesia:start().
merge the 2 DBs:
m1> net:ping('m@dumpfs-m2').
m1> mnesia:change_config(extra_db_nodes, ['c@dumpfs2']).
m1> mnesia:change_table_copy_type(schema, node(), disc_copies).
m2> mnesia:change_table_copy_type(schema, node(), disc_copies).
Nota: Em princípio estes 2 passos não são necessários
Launch mnesia on s2 to do some queries:
s2> (goto mnesia parent dir) => or just MetaData Dir
s2> erl -sname s -setcookie mnesia
s2> mnesia:start().
s2> net:ping('m@dumpfs-m1').
s2> mnesia:info().
m1> mnesia:change_config(extra_db_nodes, ['s@dumpfs-s2']).
s2> mnesia:info().
Create a new table (to be stored on m1 and m2):
s2> rd(file, {id, hash, size, node_state}). s2> rd(unique_id, {type,count}).
s2> mnesia:create_table(file, [{attributes, record_info(fields, file)}, {disc_copies, ['c@dumpfs1','c@dumpfs2']}]).
s2> mnesia:create_table(unique_id, [{attributes, record_info(fields, unique_id)}, {disc_copies, ['c@dumpfs1','c@dumpfs2']}]).
s2> mnesia:info().
Insert new data (to be stored on m1 and m2):
s2> mnesia:activity(transaction, fun() -> mnesia:write(#file{id = “123”, hash = “b23487tfv”, size = “432”}) end).
s2> mnesia:activity(transaction, fun() -> mnesia:write(#file{id = “abc”, hash = “b23487tfv”, size = “432”}) end).
Verify that the data was inserted:
s2> mnesia:schema(file). => não mostra qualquer entrada??
m1> mnesia:schema(file).
m2> mnesia:schema(file).
Do some queries:
s2> mnesia:activity(transaction, fun() -> qlc:e(qlc:q([R || R <- mnesia:table(file), R#file.id == “abc” ])) end). => primeiro não deu, mas depois já??
m1> rd(file, {id, hash, size, group}).
m1> mnesia:activity(transaction, fun() -> qlc:e(qlc:q([R || R <- mnesia:table(file), R#file.id == “123” ])) end).
Shutdown and restart mnesia at s2:
s2> q().
s2> erl -sname s -setcookie mnesia
s2> mnesia:start().
s2> net:ping('m@dumpfs-m1'). => é mesmo necessário? NÃO
s2> mnesia:info().
m1> mnesia:change_config(extra_db_nodes, ['s@dumpfs-s2']).
=> é mesmo necessário correr isto no m1? Mais ou menos
Alternativa:
s2> rpc:call('m@dumpfs-m1', mnesia, change_config, [extra_db_nodes, [node()]]).
Verify that the schema is correct:
s2> mnesia:info().
s2> mnesia:schema(file).
Do some queries:
s2> rd(file, {id, hash, size, group}).
s2> mnesia:activity(transaction, fun() -> qlc:e(qlc:q([R || R <- mnesia:table(file), R#file.id == “123” ])) end).
m1> mnesia:activity(transaction, fun() -> qlc:e(qlc:q([R || R <- mnesia:table(file), R#file.id == “abc” ])) end).
Insert new data (to be stored on m1 and m2):
s2> mnesia:activity(transaction, fun() -> mnesia:write(#file{id = “456”, hash = “b23487tfv”, size = “432”}) end).
s2> mnesia:activity(transaction, fun() -> mnesia:write(#file{id = “def”, hash = “b23487tfv”, size = “432”}) end).
Verify that the data was inserted:
s2> mnesia:schema(file).
m1> mnesia:schema(file).
m2> mnesia:schema(file).
Do some queries:
s2> mnesia:activity(transaction, fun() -> qlc:e(qlc:q([R || R <- mnesia:table(file), R#file.id == “def” ])) end).
m1> mnesia:activity(transaction, fun() -> qlc:e(qlc:q([R || R <- mnesia:table(file), R#file.id == “456” ])) end).
Shutdown and restart mnesia at m1:
m1> q().
m1> erl -sname m -setcookie mnesia
m1> mnesia:start().
m1> net:ping('m@dumpfs-m2'). => não é necessário
Verify that the schema is correct:
m1> mnesia:info().
s2> mnesia:info().
m1> mnesia:schema(file).
s2> mnesia:schema().
Do some queries:
m1> rd(file, {id, hash, size, group}).
m1> mnesia:activity(transaction, fun() -> qlc:e(qlc:q([R || R <- mnesia:table(file), R#file.id == “123” ])) end).
s2> mnesia:activity(transaction, fun() -> qlc:e(qlc:q([R || R <- mnesia:table(file), R#file.id == “def” ])) end).
Recovery from network partitioning:
c1> mnesia:set_master_nodes([c@dumpfs2]).
c1> mnesia:table_info(file, master_nodes).
c1> mnesia:system_info(running_db_nodes).
The functions mnesia:add_table_copy/3 and mnesia:del_table_copy/2 may be used to add and delete replicas of the schema table. Adding a node to the list of nodes where the schema is replicated will affect two things. First it allows other tables to be replicated to this node. Secondly it will cause Mnesia to try to contact the node at start-up of disc-full nodes.
The function call mnesia:del_table_copy(schema, mynode@host) deletes the node 'mynode@host' from the Mnesia system. The call fails if mnesia is running on 'mynode@host'. The other mnesia nodes will never try to connect to that node again. Note, if there is a disc resident schema on the node 'mynode@host', the entire mnesia directory should be deleted. This can be done with mnesia:delete_schema/1. If mnesia is started again on the the node 'mynode@host' and the directory has not been cleared, mnesia's behaviour is undefined.