mongoDB使用记录

1.默认情况下,集群中primary支持读写,secondary是不支持的

需要rs.slaveOk();

测试语句:

cfg={ _id:"testrs", members:[ {_id:0,host:'xxx.xxx.xxx.xxx:19130',priority:2}, {_id:1,host:''xxx.xxx.xxx.xxx:19130',priority:1}, 

{_id:2,host:''xxx.xxx.xxx.xxx:19130',arbiterOnly:true}] };

rs.initiate(cfg)

db.test.insert({id:1,name:'francs'} );

mongo --port xxx --host xxx

猜你喜欢

转载自tcxiang.iteye.com/blog/2054872