MongoDB叢集環境儲存空間向量資料

來源:互聯網
上載者:User

之前研究了 mongodb環境搭建(見 ),考慮到今後要用到mongodb叢集環境,且多位32位OS環境,因此構建了 mongodb叢集環境。具體過程參考了“ Mongodb叢集配置(sharding with replica set)” 見 。

實驗用VMWare 8.0構建了4台XP機器,IP地址依次為192.168.111.11,192.168.111.12,192.168.111.13,192.168.111.14。

配製說明:

1、3個分區sharding,每個sharding均佔據三台機器,其中192.168.111.11為主儲存,192.168.111.12與192.168.111.13為Replica Sets。
2、3個配置節點Configsever依次佔據192.168.111.11,192.168.111.12,192.168.111.13。
3、1個路由節點Mongos在192.168.111.14運行。


sharding A的組成為: 192.168.111.11:10000   192.168.111.12:10001  192.168.111.13:10002
sharding B的組成為: 192.168.111.11:20000   192.168.111.12:20001  192.168.111.13:20002
sharding C的組成為: 192.168.111.11:30000   192.168.111.12:30001  192.168.111.13:30002
configsever組成為: 192.168.111.11:40000   192.168.111.12:40001  192.168.111.13:40002
mongos組成為: 192.168.111.14:50000  



先從mongodb官網上down下來2.0.2,然後解壓到C盤根目錄下,四台虛擬機器相同,因此可以先部署再做機器拷貝。在C目錄下建檔案夾data,data下建子目錄a,b,c,config,依次為sharding A到C服務,config目錄為configsever服務。

以下內容為服務啟動指令碼,可分別以bat形勢執行,以避免在cmd下輸入大量命令出現手誤。

構建sharding A

mongod機器192.168.111.11下,執行:

mongod.exe --logappend --dbpath c:\data\a --port 10000 --shardsvr --replSet setA --rest --oplogSize 64

mongod機器192.168.111.12下,執行:

mongod.exe --logappend --dbpath c:\data\a --port 10001 --shardsvr --replSet setA --rest --oplogSize 64

mongod機器192.168.111.13下,執行:

mongod.exe --logappend --dbpath c:\data\a --port 10002 --shardsvr --replSet setA --rest --oplogSize 64

mongos機器192.168.111.14下,執行:

call mongo.exe 192.168.111.11:10000/admin
config={_id:'setA',members:[{_id:0,host:'192.168.111.11:10000'},{_id:1,host:'192.168.111.12:10001'},{_id:2,host:'192.168.111.13:10002'}]}
rs.initiate(config)

構建sharding B

mongod機器192.168.111.11下,執行:

mongod.exe --logappend --dbpath c:\data\b --port 20000 --shardsvr --replSet setB --rest --oplogSize 64

mongod機器192.168.111.12下,執行:

mongod.exe --logappend --dbpath c:\data\b --port 20001 --shardsvr --replSet setB --rest --oplogSize 64

mongod機器192.168.111.13下,執行:

mongod.exe --logappend --dbpath c:\data\b --port 20002 --shardsvr --replSet setB --rest --oplogSize 64

mongos機器192.168.111.14下,執行:

call mongo.exe 192.168.111.11:20000/admin
config={_id:'setB',members:[{_id:0,host:'192.168.111.11:20000'},{_id:1,host:'192.168.111.12:20001'},{_id:2,host:'192.168.111.13:20002'}]}
rs.initiate(config)

構建sharding C

mongod機器192.168.111.11下,執行:

mongod.exe --logappend --dbpath c:\data\c --port 30000 --shardsvr --replSet setC --rest --oplogSize 64

mongod機器192.168.111.12下,執行:

mongod.exe --logappend --dbpath c:\data\b --port 30001 --shardsvr --replSet setC --rest --oplogSize 64

mongod機器192.168.111.13下,執行:

mongod.exe --logappend --dbpath c:\data\c --port 30002 --shardsvr --replSet setC --rest --oplogSize 64

mongos機器192.168.111.14下,執行:

call mongo.exe 192.168.111.11:30000/admin
config={_id:'setB',members:[{_id:0,host:'192.168.111.11:30000'},{_id:1,host:'192.168.111.12:30001'},{_id:2,host:'192.168.111.13:30002'}]}
rs.initiate(config)

  • 1
  • 2
  • 下一頁

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.