|
=====================================================================================
复制实验
/data/mongodb-linux-i686-1.6.0/bin/mongod -port 10001 -dbpath /data/db64160/
/data/mongodb-linux-i686-1.6.0/bin/mongod --replSet foo --port 27017 --dbpath /data/r0
/data/mongodb-linux-i686-1.6.0/bin/mongod --replSet foo --port 27018 --dbpath /data/r1
/data/mongodb-linux-i686-1.6.0/bin/mongod --replSet foo --port 27019 --dbpath /data/r2
启动客户端:
/data/mongodb-linux-i686-1.6.0/bin/mongo localhost:27017
> config = {_id: 'foo', members: [
{_id: 0, host: 'localhost:27017'},
{_id: 1, host: 'localhost:27018'},
{_id: 2, host: 'localhost:27019'}]
}
> rs.initiate(config);
> db.messages.save({name: "ReplSet Tutorial"});
--去3个node去验证数据 fail
/data/mongodb-linux-i686-1.6.0/bin/mongo localhost:27017
--重新配置
> new_config = {_id: 'foo', members: [
{_id: 0, host: 'localhost:27017', votes: 1},
{_id: 1, host: 'localhost:27018', votes: 2},
{_id: 2, host: 'localhost:27019', votes: 3}]
} |
|