mongodb 主从服务器

@set mongod=..\bin\mongod.exe

set keyFile=key.key

if not exist %keyFile% (
echo 123456>%keyFile%
)

md %1 2>nul 1>nul

%mongod% --port %1 --replSet %2 --dbpath %1 --logpath %1\_output_%1.log %3 %4 %5 %6

::接着运行↓
config_rs1 = {
    _id: "rs",
    members: [{
        _id: 0,
        host: "127.0.0.1:27017",
        priority: 4
    },
    {
        _id: 1,
        host: "127.0.0.1:27018",
        priority: 3
    },
    {
        _id: 2,
        host: "127.0.0.1:27019",
        priority: 2
    },
    {
        _id: 3,
        host: "127.0.0.1:27020",
        priority: 1
    }]
};

rs.initiate(config_rs1);

 

posted @ 2013-08-21 17:04  Arliang  阅读(207)  评论(0编辑  收藏  举报