mongodb的备份还原案例(四)
[root@Mongodb-B test]#
[root@Mongodb-B test]# /Apps/mongo/bin/mongorestore -d test --drop /usr/local/dump/test/ -------执行mongorestore命令,目前只是恢复单独一个test库
connected to: 127.0.0.1
Wed Jul 3 01:20:30.574 /usr/local/dump/test/code.bson
Wed Jul 3 01:20:30.574 going into namespace [test.code]
Wed Jul 3 01:20:30.574 dropping
28 objects found
Wed Jul 3 01:20:30.576 Creating index: { key: { _id: 1 }, ns: "test.code", name: "_id_" }
Wed Jul 3 01:20:30.796 /usr/local/dump/test/user.bson
Wed Jul 3 01:20:30.796 going into namespace [test.user]
Wed Jul 3 01:20:30.796 dropping
5 objects found
Wed Jul 3 01:20:30.798 Creating index: { key: { _id: 1 }, ns: "test.user", name: "_id_" }
[root@Mongodb-B test]# /Apps/mongo/bin/mongo
MongoDB shell version: 2.4.4
connecting to: test
Server has startup warnings:
Wed Jul 3 01:05:59.682 [initandlisten]
Wed Jul 3 01:05:59.682 [initandlisten] ** NOTE: This is a 32 bit MongoDB binary.
Wed Jul 3 01:05:59.682 [initandlisten] ** 32 bit builds are limited to less than 2GB of data (or less with --journal).
Wed Jul 3 01:05:59.682 [initandlisten] ** Note that journaling defaults to off for 32 bit and is currently off.
Wed Jul 3 01:05:59.682 [initandlisten] ** See http://dochub.mongodb.org/core/32bit
Wed Jul 3 01:05:59.682 [initandlisten]
> show dbs;
admin (empty)
local 0.03125GB
test 0.0625GB
> use test;
switched to db test
> show tables;
code
system.indexes
user
> db.user.find(); ----校验信息的完整性;
{ "_id" : ObjectId("51cc51275e0cd84ee2e58d72"), "name" : "songxixi" }
{ "_id" : ObjectId("51cc512a5e0cd84ee2e58d73"), "name" : "songxixi" }
{ "_id" : ObjectId("51cc512a5e0cd84ee2e58d74"), "name" : "songxixi" }
{ "_id" : ObjectId("51cc512b5e0cd84ee2e58d75"), "name" : "songxixi" }
{ "_id" : ObjectId("51cc512b5e0cd84ee2e58d76"), "name" : "songxixi" }
>
db.code.find() ----校验信息的完整性;
{ "_id" : ObjectId("51cc521b93fcb9607a1d4d2a"), "name" : "song" }
{ "_id" : ObjectId("51cc521c93fcb9607a1d4d2b"), "name" : "song" }
{ "_id" : ObjectId("51cc521c93fcb9607a1d4d2c"), "name" : "song" }
{ "_id" : ObjectId("51cc521d93fcb9607a1d4d2d"), "name" : "song" }
{ "_id" : ObjectId("51cc521d93fcb9607a1d4d2e"), "name" : "song" }
{ "_id" : ObjectId("51cc521e93fcb9607a1d4d2f"), "name" : "song" }
{ "_id" : ObjectId("51cc521e93fcb9607a1d4d30"), "name" : "song" }
{ "_id" : ObjectId("51cc521f93fcb9607a1d4d31"), "name" : "song" }
{ "_id" : ObjectId("51cc522093fcb9607a1d4d32"), "name" : "song" }
{ "_id" : ObjectId("51cc522093fcb9607a1d4d33"), "name" : "song" }
{ "_id" : ObjectId("51cc522193fcb9607a1d4d34"), "name" : "song" }
{ "_id" : ObjectId("51cc522293fcb9607a1d4d35"), "name" : "song" }
{ "_id" : ObjectId("51cc522393fcb9607a1d4d36"), "name" : "song" }
{ "_id" : ObjectId("51cc522393fcb9607a1d4d37"), "name" : "song" }
{ "_id" : ObjectId("51cc522493fcb9607a1d4d38"), "name" : "song" }
{ "_id" : ObjectId("51cc522593fcb9607a1d4d39"), "name" : "song" }
{ "_id" : ObjectId("51cc522593fcb9607a1d4d3a"), "name" : "song" }
{ "_id" : ObjectId("51cc522693fcb9607a1d4d3b"), "name" : "song" }
{ "_id" : ObjectId("51cc522793fcb9607a1d4d3c"), "name" : "song" }
{ "_id" : ObjectId("51cc522893fcb9607a1d4d3d"), "name" : "song" }
Type "it" for more
>
>
>
>
> db.system.indexes.find() ------校验索引的完整性,有时候迁移数据索引容易丢失,索引是进行校验的重点项目;重建索引在大数据下回很漫长
{ "v" : 1, "key" : { "_id" : 1 }, "ns" : "test.code", "n