国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > MongoDB > 正文

MongoDB整庫備份與還原以及單個collection備份、恢復方法

2020-10-29 18:54:49
字體:
來源:轉載
供稿:網友
mongodump.exe備份的原理是通過一次查詢獲取當前服務器快照,并將快照寫入磁盤中,因此這種方式保存的也不是實時的,因為在獲取快照后,服務器還會有數據寫入,為了保證備份的安全,同樣我們還是可以利用fsync鎖使服務器數據暫時寫入緩存中。

高效開源數據庫(mongodb)下載地址:http://www.survivalescaperooms.com/softs/41751.html

備份前的檢查
> show dbs
MyDB 0.0625GB
admin (empty)
bruce 0.0625GB
local (empty)
test 0.0625GB
> use MyDB
switched to db MyDB
> db.users.find()
{ "_id" : ObjectId("4e290aa39a1945747b28f1ee"), "a" : 1, "b" : 1 }
{ "_id" : ObjectId("4e2cd2182a65c81f21566318"), "a" : 3, "b" : 5 }
>

整庫備份:
mongodump -h dbhost -d dbname -o dbdirectory
-h:MongDB所在服務器地址,例如:127.0.0.1,當然也可以指定端口號:127.0.0.1:27017
-d:需要備份的數據庫實例,例如:test
-o:備份的數據存放位置,例如:c:/data/dump,當然該目錄需要提前建立,在備份完成后,系統自動在dump目錄下建立一個test目錄,這個目錄里面存放該數據庫實例的備份數據。

mongodump的官方說明(可通過mongodump --help查看):options: --help          produce help message -v [ --verbose ]     be more verbose (include multiple times for more              verbosity e.g. -vvvvv) --version        print the program's version and exit -h [ --host ] arg    mongo host to connect to ( /s1,s2 for              sets) --port arg        server port. Can also use --host hostname:port --ipv6          enable IPv6 support (disabled by default) -u [ --username ] arg  username -p [ --password ] arg  password --dbpath arg       directly access mongod database files in the given              path, instead of connecting to a mongod server -              needs to lock the data directory, so cannot be used              if a mongod is currently accessing the same path --directoryperdb     if dbpath specified, each db is in a separate              directory --journal        enable journaling -d [ --db ] arg     database to use -c [ --collection ] arg collection to use (some commands) -o [ --out ] arg (=dump) output directory or "-" for stdout -q [ --query ] arg    json query --oplog         Use oplog for point-in-time snapshotting --repair         try to recover a crashed database --forceTableScan     force a table scan (do not use $snapshot)

整庫恢復:
mongorestore -h dbhost -d dbname

主站蜘蛛池模板: 诏安县| 邢台市| 凤阳县| 夏津县| 河津市| 长沙市| 金阳县| 德安县| 读书| 兴文县| 沙洋县| 陵水| 镇远县| 石泉县| 章丘市| 宁河县| 万盛区| 二手房| 昌江| 奉节县| 丰顺县| 丹寨县| 蓝山县| 龙川县| 响水县| 望江县| 长海县| 朝阳县| 宁河县| 常宁市| 法库县| 思南县| 柳河县| 郧西县| 城步| 新巴尔虎左旗| 招远市| 平凉市| 崇信县| 红安县| 万荣县|