mongo主从复制

1、启动主

root@test:/usr/local/mongodb/slave_log# /home/test/mongodb/bin/mongod --dbpath=/usr/local/mongodb/mongodb_data/ --logpath=/usr/local/mongodb/mongodb_log/mongodb.log --logappend --fork --master
2、启动从
root@test:/home/test# /home/test/mongodb/bin/mongod --dbpath=/usr/local/mongodb/slave_data/ --logpath=/usr/local/mongodb/slave_log/mongodb.log --logappend --fork --slave --source 127.0.0.1:27017 --port 27019
3、登录主
root@test:/usr/local/mongodb/slave_log# mongo
MongoDB shell version: 1.8.1
connecting to: test
> show tables;
c1
c2
c3
fs.chunks
fs.files
system.indexes
system.profile
>

> db.getMongo();
connection to 127.0.0.1
>

4、登录从
root@test:/home/test# /home/test/mongodb/bin/mongo --port 27019
MongoDB shell version: 1.8.1
connecting to: 127.0.0.1:27019/test
> use test
switched to db test
> show tables;
c1
c2
c3
fs.chunks
fs.files
system.indexes
>

> db.getMongo();
connection to 127.0.0.1:27019
>

    A+
发布日期:2013年12月08日  所属分类:未分类

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: