MongoDB叢集配置

來源:互聯網
上載者:User

標籤:

本文示範:(一個主伺服器,一個備份伺服器,三個仲裁伺服器)

官方推薦複本集的成員數量為奇數,最多12個複本集節點,最多7個節點參與選舉。

本文示範基於本機,用連接埠區分服務(每個伺服器下建立db檔案夾用於儲存資料,mongodb.conf檔案配置啟動參數)

各個伺服器設定檔內容如下:

27000主伺服器

dbpath=D:\MongoDB\Server27000\3.2\db

port=27000

replSet=datamip/127.0.0.1:27001

//複本集下面有其他伺服器27001

27001備份伺服器

dbpath=D:\MongoDB\Server27001\3.2\db

port=27001

replSet=datamip/127.0.0.1:27000

//主伺服器

27002仲裁伺服器

dbpath=D:\MongoDB\Server27002\3.2\db

port=27002

replSet=datamip/127.0.0.1:27001

//主伺服器

27003仲裁伺服器

dbpath=D:\MongoDB\Server27003\3.2\db

port=27003

replSet=datamip/127.0.0.1:27001

//主伺服器

27004仲裁伺服器

dbpath=D:\MongoDB\Server27004\3.2\db

port=27004

replSet=datamip/127.0.0.1:27001

//主伺服器

27000主伺服器27001備份伺服器27002仲裁伺服器27003仲裁伺服器27004仲裁伺服器建立服務sc.exe create MongoDB27000 binPath= "C:\MongoDB\Server27000\bin\mongod.exe --service --config=\"C:\MongoDB\Server27000\mongodb.conf"" DisplayName= "MongoDB27000" start= "auto"sc.exe create MongoDB27001 binPath= "C:\MongoDB\Server27001\bin\mongod.exe --service --config=\"C:\MongoDB\Server27001\mongodb.conf"" DisplayName= "MongoDB27001" start= "auto"sc.exe create MongoDB27002 binPath= "C:\MongoDB\Server27002\bin\mongod.exe --service --config=\"C:\MongoDB\Server27002\mongodb.conf"" DisplayName= "MongoDB27002" start= "auto"sc.exe create MongoDB27003 binPath= "C:\MongoDB\Server27003\bin\mongod.exe --service --config=\"C:\MongoDB\Server27003\mongodb.conf"" DisplayName= "MongoDB27003" start= "auto"sc.exe create MongoDB27004 binPath= "C:\MongoDB\Server27004\bin\mongod.exe --service --config=\"C:\MongoDB\Server27004\mongodb.conf"" DisplayName= "MongoDB27004" start= "auto"啟動服務>mongo 192.168.200.111:27000/admin//串連primary>db.runCommand({"replSetInitiate":{"_id":"datamip","members":[{"_id":1,"host":"192.168.200.111:27000"},{"_id":2,"host":"192.168.200.111:27001"}]}}) 稍等片刻,等待27000變為primary時添加如下配置>mongo 192.168.200.111:27000/admin>rs.addArb("192.168.200.111:27002")>rs.addArb("192.168.200.11127003")>rs.addArb("192.168.200.111:27004")

MongoDB叢集配置

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.