动态增删Mnesia数据库节点

2009-04-10
Mnesia支持动态的增删节点以进行数据转移或备份:
首先启动新节点上面的mnesia
> rpc:call(Node, mnesia, start, []).
添加新节点
> {ok, _} = mnesia:change_config(extra_db_nodes, [Node]).
修改新节点上的schema表的类型
> {atomic, ok} = mnesia:change_table_copy_type(schema, Node, disc_copies).

OK,现在可以在新节点上添加表备份、分块等等了,如果不再需要某个节点,可以这样删除节点:
首先关闭该节点上的mnesia
> rpc:call(Node, mnesia, stop, []).
删掉该节点上的schema表
> {atomic, ok} = mnesia:del_table_copy(schema, Node).
> ok = mnesia:delete_schema([Node]).

M-OSCAR | Powered by Blogger | Entries (RSS) | Comments (RSS) | Designed by MB Web Design | XML Coded By Cahayabiru.com