可以看到主数据库允许192.168.2.3从59172进行连接
四、测试主从复制
主:192.168.2.2
创建一个数据库test,集合名也是test,插入一个字段AGE:18。然后再到从数据库执行show dbs;查看已经同步过去。
[root@localhost conf]# mongo
MongoDB shell version: 2.2.6
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
http://docs.mongodb.org/
Questions? Try the support group
http://groups.google.com/group/mongodb-user
> show dbs;
local4.013671875GB
> use test;
switched to db test
> db.test.save({"AGE":18})
> db.test.find()
{ "_id" : ObjectId("534f592ce7b706845c58740b"), "AGE" : 18 }
> show dbs
local4.013671875GB
test0.203125GB
从:192.168.2.3
[root@localhost conf]# mongo
MongoDB shell version: 2.2.6
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
http://docs.mongodb.org/
Questions? Try the support group
http://groups.google.com/group/mongodb-user
> show dbs
local4.013671875GB
test0.203125GB
并查看从库上的日志,可以看到同步的行为