下面是官網上關于 Master-Slaver模式主備切換步驟
1、 Halt writes on A using the fsync command.
2、Make sure B is up to date with the state of A.
3、 Shut down B.
4、Back up and move all data files that begin with local on B from the dbPath to remove the existing local.sources data.
Warning
Removing local.* is irrevocable and cannot be undone. Perform this step with extreme caution.
5、Start B with the --master option.
6、Do a write on B, which primes the oplog to provide a new sync start point.
7、Shut down B. B will now have a new set of data files that start with local.
8、Shut down A and replace all files in the dbPath of A that start with local with a copy of the files in the dbPath of B that begin with local.
9、Considering compressing the local files from B while you copy them, as they may be quite large.
10、Start B with the --master option.
11、Start A with all the usual slave options, but include fastsync.
關于第三步我不很明白,洗掉local.source data,這個local.sources data是哪個檔案
uj5u.com熱心網友回復:
Master-Slaver你可以理解為已經廢棄了uj5u.com熱心網友回復:
目前只有兩臺主機,需要搭建熱備,故只能使用master-slave模式,local.sources可以通過use local;db.sources.stats().wiredTiger.uri來查找到,但是我移除了這個檔案,mongoDB無法啟動,報WiredTiger error (2) [1520299616:34915][30051:0x7f2831ba2d80], file:local/collection-0--2786426632940137551.wt, WT_SESSION.open_cursor: /var/lib/mongodb/data/db/local/collection-0--2786426632940137551.wt: handle-open: open: No such file or directoryuj5u.com熱心網友回復:
應該搭建replicat set 翻譯過來是 副本集模式uj5u.com熱心網友回復:
replicat set 需要3臺主機,主,備,仲裁,目前有個環境只有兩臺主機,無法搭建replicat setuj5u.com熱心網友回復:
兩臺也可以 仲裁放到其中一臺上埠不一致即可(雖然這樣不推薦)uj5u.com熱心網友回復:
這樣不是無法保證熱備正常了,如果主和仲裁在同一臺主機上,這臺主機掛了,備也無法接管服務,master-slave雖然也無法自動切換,但是可以通過自定義腳本來切換uj5u.com熱心網友回復:
可以把仲裁節點放在一個web機器上,僅僅是一個行程而已轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/95185.html
標籤:MongoDB
