解決mongodb數(shù)據(jù)庫(kù)備份不完整的方法

小編給大家分享一下解決MongoDB數(shù)據(jù)庫(kù)備份不完整的方法,希望大家閱讀完這篇文章后大所收獲,下面讓我們一起去探討吧!

十載的柳州網(wǎng)站建設(shè)經(jīng)驗(yàn),針對(duì)設(shè)計(jì)、前端、開發(fā)、售后、文案、推廣等六對(duì)一服務(wù),響應(yīng)快,48小時(shí)及時(shí)工作處理。成都營(yíng)銷網(wǎng)站建設(shè)的優(yōu)勢(shì)是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動(dòng)調(diào)整柳州建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無(wú)論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。創(chuàng)新互聯(lián)從事“柳州網(wǎng)站設(shè)計(jì)”,“柳州網(wǎng)站推廣”以來(lái),每個(gè)客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。

Mongodb自帶了mongodump和mongorestore這兩個(gè)工具來(lái)實(shí)現(xiàn)對(duì)數(shù)據(jù)的備份和恢復(fù)。

mongodump能夠在Mongodb運(yùn)行時(shí)進(jìn)行備份,它的工作原理是對(duì)運(yùn)行的Mongodb做查詢,然后將所有查到的文檔寫入磁盤。

所以一般使用此方法對(duì)數(shù)據(jù)庫(kù)進(jìn)行備份時(shí)數(shù)據(jù)是不完整的。

mongodump用法:

C:\Users\Administrator>D:\tool\mongo\bin\mongodump --help
Export MongoDB data to BSON files.

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 ( <set
                                        name>/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
  --authenticationDatabase arg          user source (defaults to dbname)
  --authenticationMechanism arg (=MONGODB-CR)
                                        authentication mechanism
  --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                      each db is in a separate directly
                                        (relevant only if dbpath specified)
  --journal                             enable journaling (relevant only if
                                        dbpath specified)
  -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)

參數(shù)說(shuō)明:

-h:指明數(shù)據(jù)庫(kù)宿主機(jī)的IP

-u:指明數(shù)據(jù)庫(kù)的用戶名

-p:指明數(shù)據(jù)庫(kù)的密碼

-d:指明數(shù)據(jù)庫(kù)的名字

-c:指明collection的名字

-o:指明到要導(dǎo)出的文件名

-q:指明導(dǎo)出數(shù)據(jù)的過(guò)濾條件

備份的命令:

mongodump -h dbhost -d dbname -o dbdirectory

如果mongodb設(shè)置了登錄驗(yàn)證,則不能備份成功,報(bào)錯(cuò)如下:

assertion: 18 { code: 18, ok: 0.0, errmsg: "auth fails" }

則需要登錄,命令如下:

C:\Users\Administrator>D:\tool\mongo\bin\mongodump -username root -password 12345
6 -d test -o d:\tool\mongo\backup

若要備份全部數(shù)據(jù)庫(kù)文件可以使用下面的命令進(jìn)行備份:

C:\Users\Administrator>D:\tool\mongo\bin\mongodump -u root -p 12345

或使用rsync直接拉去數(shù)據(jù)。

看完了這篇文章,相信你對(duì)解決mongodb數(shù)據(jù)庫(kù)備份不完整的方法有了一定的了解,想了解更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!

新聞名稱:解決mongodb數(shù)據(jù)庫(kù)備份不完整的方法
網(wǎng)頁(yè)網(wǎng)址:http://www.muchs.cn/article2/jsodoc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供做網(wǎng)站、虛擬主機(jī)、網(wǎng)站改版、ChatGPT、Google、定制開發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站建設(shè)