如果运行在各个节点的mnesia可以动态加载动态去掉,这样mnesia可以根据各种需要进行动态增加和删除其他节点而不必在启动的时候一一连接起来,那想必是极好的。
mnesia动态加载其他节点可以通过mnesia:change_config(extra_db_nodes, NodeList)实现,但是,如果[node() | NodeList]中,有两个以上disc_copies类型的node,那该方法会报错
{error,{merge_schema_failed,"Incompatible schema cookies. Please, restart from old backup.a@localhost = [{name,schema},{type,set},{ram_copies,[]},{disc_copies,[a@localhost]},{disc_only_copies,[]},{load_order,0},{access_mode,read_write},{majority,false},{index,[]},{snmp,[]},{local_content,false},{record_name,schema},{attributes,[table,cstruct]},{user_properties,[]},{frag_properties,[]},{storage_properties,[]},{cookie,{{1400,753431,255034},a@localhost}},{version,{{2,0},[]}}], b@localhost = [{name,schema},{type,set},{ram_copies,[]},{disc_copies,[b@localhost]},{disc_only_copies,[]},{load_order,0},{access_mode,read_write},{majority,false},{index,[]},{snmp,[]},{local_content,false},{record_name,schema},{attributes,[table,cstruct]},{user_properties,[]},{frag_properties,[]},{storage_properties,[]},{cookie,{{1400,753475,314226},b@localhost}},{version,{{2,0},[]}}]\n"}}
并且,同名的表如果结构、类型等等不同该方法也是不能成功的。
mnesia:add_table_copy(schema, Node, ram_copies)可以在两个以上disc_copies的node上加载吗,试验证明,可以。但是,你会发现这样加载的节点死活都是stop node。
关于rabbitmq的mnesia动态加载,参考http://blog.youkuaiyun.com/zhangxinrun/article/details/6536394,http://www.cnblogs.com/me-sa/archive/2012/11/12/2767036.html