MongoDB Sharding 集群配置示例(2)

server2:
cd /home/mongodb/mongodb-linux-x86_64-1.6.2/bin
./mongod –shardsvr –replSet shard2 –port 27018 –dbpath /home/mongodb/data/shard22 –oplogSize 100 –logpath /home/mongodb/data/shard22.log –logappend –fork

server3:
cd /home/mongodb/mongodb-linux-x86_64-1.6.2/bin
./mongod –shardsvr –replSet shard2 –port 27018 –dbpath /home/mongodb/data/shard23 –oplogSize 100 –logpath /home/mongodb/data/shard23.log –logappend –fork

初始化replica set
用mongo连接其中一个mongod,执行:
> config = {_id: ‘shard2′, members: [
                          {_id: 0, host: '10.1.1.1:27018'},
                          {_id: 1, host: '10.1.1.2:27018'},
                          {_id: 2, host: '10.1.1.3:27018'}]
           }

> rs.initiate(config);

到此就配置好了二个replica sets,也就是准备好了二个shards

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/pppys.html