$ mongodb/bin/mongo --port 28018
MongoDB shell version: 1.2.4-
url: test
connecting to: 127.0.0.1:28018/test
type "help" for help
> show dbs
admin
local
test
> use test
switched to db test
> show collections 这里主上的test数据什么表都没有,为空,查看从服务器同样也是这样
$ mongodb/bin/mongo --port 28019
MongoDB shell version: 1.2.4-
url: test
connecting to: 127.0.0.1:28019/test
type "help" for help
> show dbs
admin
local
test
> use test
switched to db test
> show collections 那么现在我们来验证主从数据是否会像想象的那样同步呢?
我们在主上新建表user
> db
test
>db.createCollection("user");
> show collections
system.indexes
user
> 表user已经存在了,而且test库中还多了一个system.indexes用来存放索引的表
到从服务器上查看test库:
> db
test
> show collections
system.indexes
User
> db.user.find();
> 从服务器的test库中user表已经存在,同时我还查了一下user表为空