中文字幕第五页-中文字幕第页-中文字幕韩国-中文字幕最新-国产尤物二区三区在线观看-国产尤物福利视频一区二区

MongoDB分片(Cluster)-創新互聯

基本環境:

十載的新和網站建設經驗,針對設計、前端、開發、售后、文案、推廣等六對一服務,響應快,48小時及時工作處理。成都全網營銷推廣的優勢是能夠根據用戶設備顯示端的尺寸不同,自動調整新和建站的顯示方式,使網站能夠適用不同顯示終端,在瀏覽器中調整網站的寬度,無論在任何一種瀏覽器上瀏覽網站,都能展現優雅布局與設計,從而大程度地提升瀏覽體驗。創新互聯從事“新和網站設計”,“新和網站推廣”以來,每個客戶項目都認真落實執行。

由于資源緊張,只有3臺虛擬機的關系,只做兩個replicaSet,每臺機器配置分別如下:

10.10.1.55這臺機器安裝 Primary1,configServer1, Arbiter1

10.10.1.56 安裝 Primary2,configServer2, Arbiter2

10.10.1.57 安裝 Secondary1,Secondary2,configServer3,mongos

1.55機器的配置文件如下:

Primary1的conf文件:

dbpath=/data/mongodb/rs0_0 logpath=/data/mongodb/log/rs0_0.log logappend=true port=40000 bind_ip=192.168.11.55,10.10.1.55 oplogSize=10000 fork=true journal = true #noprealloc = true replSet=rs0 directoryperdb=true

Arbiter1的配置文件:

dbpath=/data/mongodb/rs0_arbiter logpath=/data/mongodb/log/rs0_arbiter.log logappend=true port=40002 bind_ip=192.168.11.55,10.10.1.55 oplogSize=10000 fork=true journal = true #noprealloc = true replSet=rs0 directoryperdb=true

ConfigServer1的配置文件:

dbpath=/data/mongodb/rs0_conf logpath=/data/mongodb/log/rs0_conf.log logappend=true port=40006 bind_ip=192.168.11.55,10.10.1.55 fork=true journal = true #noprealloc = true configsvr=true directoryperdb=true

分別通過mongod --config filename 來啟動不同的mongo 進程,成功啟動后可以通過netstat 查看在1.55 機器上分別分配了Primary1端口:40000,Arbiter1端口:40002,configureServer1端口:40006

1.56機器的配置:

Primary2的配置文件:

dbpath=/data/mongodb/rs1_primary logpath=/data/mongodb/log/rs1_p.log logappend=true bind_ip=192.168.11.56,10.10.1.56 directoryperdb=true   port=40003 oplogSize=10000 fork=true journal = true noprealloc = true replSet=rs1

Arbiter2配置文件:

dbpath=/data/mongodb/rs1_arbiter logpath=/data/mongodb/log/rs1_a.log logappend=true bind_ip=192.168.11.56,10.10.1.56 directoryperdb=true   port=40005 oplogSize=10000 fork=true journal = true noprealloc = true replSet=rs1

ConfigureServer2配置文件:

dbpath=/data/mongodb/rs1_conf logpath=/data/mongodb/log/rs1_conf.log logappend=true bind_ip=192.168.11.56,10.10.1.56 directoryperdb=true   port=40007 oplogSize=10000 fork=true journal = true noprealloc = true configsvr=true

分別通過mongod --config filename 來啟動不同的mongo 進程,成功啟動后可以通過netstat 查看在1.55 機器上分別分配了Primary2端口:40003,Arbiter2端口:40005,configureServer2端口:40007

1.56機器的配置:

rs0_Secondary1配置:

dbpath=/data/mongodb/rs0_secondary1 logpath=/data/mongodb/log/rs0_secondary1.log logappend=true port=40001 bind_ip=192.168.11.57,10.10.1.57 oplogSize=10000 fork=true journal = true #noprealloc = true replSet=rs0 directoryperdb=true

rs1_Secondary1配置:

dbpath=/data/mongodb/rs1_secondary1 logpath=/data/mongodb/log/rs1_secondary1.log logappend=true bind_ip=192.168.11.57,10.10.1.57 directoryperdb=true   port=40004 oplogSize=10000 fork=true journal = true noprealloc = true replSet=rs1

configureServer3配置:

dbpath=/data/mongodb/confSvr3 logpath=/data/mongodb/log/conf3.log logappend=true bind_ip=192.168.11.57,10.10.1.57 directoryperdb=true   port=40008 oplogSize=10000 fork=true journal = true configsvr=true

mongos 配置:(啟動mongos路由器要注意多臺服務器時間必須要同步,否則出現錯誤)

logpath=/data/mongodb/log/mongos.log port = 40009 configdb=10.10.1.55:40006,10.10.1.56:40007,10.10.1.57:40008 fork = true

分別通過mongod --config filename 來啟動不同的mongo 進程,成功啟動后可以通過netstat 查看在1.55 機器上分別分配了rs0_secondary1端口:40001,rs1_secondary1端口:40004,configureServer3端口:40008,mongos路由端口:40009

現在用mongo shell登錄primary1 配置replicaSet0,步驟如下:

cfg={ "_id" : "rs0", "members" : [ { "_id" : 0, "host" : "10.10.1.55:40000" }, { "_id" : 1, "host" : "10.10.1.57:40001" } ] }

rs.initiate(cfg)
rs.status()

rs.addArb("10.10.1.55:40002")

現在用mongo shell登錄primary2 配置replicaSet1,步驟如下:

cfg={ "_id" : "rs1", "members" : [ { "_id" : 0, "host" : "10.10.1.56:40003" }, { "_id" : 1, "host" : "10.10.1.57:40004" } ] }

rs.initiate(cfg)
rs.status()

rs.addArb("10.10.1.56:40005")

使用mongo shell登錄mongos路由添加分片信息:

mongo --host 10.10.1.57 --port 40009 mongos> sh.addShard("rs0/10.10.1.55:40000,10.10.1.57:40001") { "shardAdded" : "rs0", "ok" : 1 } mongos> sh.addShard("rs1/10.10.1.56:40003,10.10.1.57:40004") { "shardAdded" : "rs1", "ok" : 1 } mongos> sh.status() --- Sharding Status ---    sharding version: {     "_id" : 1,     "version" : 4,     "minCompatibleVersion" : 4,     "currentVersion" : 5,     "clusterId" : ObjectId("561c7bdd4315b18f9862adb4") }   shards:     {  "_id" : "rs0",  "host" : "rs0/10.10.1.55:40000,10.10.1.57:40001" }     {  "_id" : "rs1",  "host" : "rs1/10.10.1.56:40003,10.10.1.57:40004" }   databases:     {  "_id" : "admin",  "partitioned" : false,  "primary" : "config" }

現在創建一個新的數據庫來測試一下分片:

mongos> use people
switched to db people
mongos> for(var i=1;i<10;i++) db.customers.insert({name:"jordan"+i,country:"American"})
WriteResult({ "nInserted" : 1 })
mongos> for(var i=1;i<10;i++) db.customers.insert({name:"gaga"+i,country:"American"})
WriteResult({ "nInserted" : 1 })
mongos> for(var i=1;i<10;i++) db.customers.insert({name:"ham"+i,country:"UK"})
WriteResult({ "nInserted" : 1 })
mongos> for(var i=1;i<10;i++) db.customers.insert({name:"brown"+i,country:"UK"})
WriteResult({ "nInserted" : 1 })
mongos> for(var i=1;i<10;i++) db.customers.insert({name:"ramda"+i,country:"Malaysia"})
WriteResult({ "nInserted" : 1 })

開始建立分片:

mongos> db.customers.ensureIndex({country:1,_id:1}) {     "raw" : {         "rs0/10.10.1.55:40000,10.10.1.57:40001" : {             "createdCollectionAutomatically" : false,             "numIndexesBefore" : 1,             "numIndexesAfter" : 2,             "ok" : 1         }     },     "ok" : 1 } mongos> sh.shardCollection("people.customers",{country:1,_id:1}) { "collectionsharded" : "people.customers", "ok" : 1 } mongos> sh.status() --- Sharding Status ---    sharding version: {     "_id" : 1,     "version" : 4,     "minCompatibleVersion" : 4,     "currentVersion" : 5,     "clusterId" : ObjectId("561c7bdd4315b18f9862adb4") }   shards:     {  "_id" : "rs0",  "host" : "rs0/10.10.1.55:40000,10.10.1.57:40001" }     {  "_id" : "rs1",  "host" : "rs1/10.10.1.56:40003,10.10.1.57:40004" }   databases:     {  "_id" : "admin",  "partitioned" : false,  "primary" : "config" }     {  "_id" : "test",  "partitioned" : false,  "primary" : "rs0" }     {  "_id" : "people",  "partitioned" : true,  "primary" : "rs0" }         people.customers             shard key: { "country" : 1, "_id" : 1 }             chunks:                 rs0    1             { "country" : { "$minKey" : 1 }, "_id" : { "$minKey" : 1 } } -->> { "country" : { "$maxKey" : 1 }, "_id" : { "$maxKey" : 1 } } on : rs0 Timestamp(1, 0)

現在由于數據量不多只有一個分片在rs0上,可以通過增加數據量來提高分片:

for(var i=10;i<10000;i++) db.customers.insert({name:"ham"+i,country:"UK"}) for(var i=10;i<10000;i++) db.customers.insert({name:"ramda"+i,country:"Malaysia"})

mongos> sh.status()
--- Sharding Status ---
 sharding version: {
   "_id" : 1,
   "version" : 4,
   "minCompatibleVersion" : 4,
   "currentVersion" : 5,
   "clusterId" : ObjectId("561c7bdd4315b18f9862adb4")
}
 shards:
   { "_id" : "rs0", "host" : "rs0/10.10.1.55:40000,10.10.1.57:40001" }
   { "_id" : "rs1", "host" : "rs1/10.10.1.56:40003,10.10.1.57:40004" }
 databases:
   { "_id" : "admin", "partitioned" : false, "primary" : "config" }
   { "_id" : "test", "partitioned" : false, "primary" : "rs0" }
   { "_id" : "people", "partitioned" : true, "primary" : "rs0" }
      people.customers
         shard key: { "country" : 1, "_id" : 1 }
         chunks:
            rs1   2
            rs0   1
         { "country" : { "$minKey" : 1 }, "_id" : { "$minKey" : 1 } } -->> { "country" : "American", "_id" : ObjectId("561c7da73af7c7865defefb1") } on : rs1 Timestamp(2, 0)
         { "country" : "American", "_id" : ObjectId("561c7da73af7c7865defefb1") } -->> { "country" : "UK", "_id" : ObjectId("561c7db63af7c7865defefd4") } on : rs0 Timestamp(3, 1)
         { "country" : "UK", "_id" : ObjectId("561c7db63af7c7865defefd4") } -->> { "country" : { "$maxKey" : 1 }, "_id" : { "$maxKey" : 1 } } on : rs1 Timestamp(3, 0)

現在rs0上有一個分片,rs1上有兩個分片

另外有需要云服務器可以了解下創新互聯cdcxhl.cn,海內外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業上云的綜合解決方案,具有“安全穩定、簡單易用、服務可用性高、性價比高”等特點與優勢,專為企業上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。

當前名稱:MongoDB分片(Cluster)-創新互聯
本文地址:http://www.2m8n56k.cn/article34/dsijse.html

成都網站建設公司_創新互聯,為您提供營銷型網站建設企業網站制作品牌網站設計云服務器網站營銷ChatGPT

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:[email protected]。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

網站托管運營
主站蜘蛛池模板: 精品久久久久久免费影院 | 亚洲精品网址 | 日韩一级特黄毛片在线看 | 韩国自拍偷自拍亚洲精品 | 久久久精品久久 | 一区二区三区中文 | 国产精品hd在线播放 | 在线观看香蕉免费啪在线观看 | 亚洲成a人片在线网站 | 久草在线免费资源 | 久久九九视频 | 国产合集91合集久久日 | 国产三级网 | 精品视频一区二区三区免费 | 一级做a爱过程免费视 | 在线播放波多野结衣 | 一级做a爰片久久毛片看看 一级做a爰片久久毛片鸭王 | 91精品国产91久久久久青草 | 九九在线精品视频播放 | 久草视频在线免费播放 | 国产精品久久久久久久久久影院 | 99久久久久国产 | 99久久精品免费国产一区二区三区 | 午夜一区二区福利视频在线 | 国产做国产爱免费视频 | 欧美日韩视频一区二区 | 亚洲夜色夜色综合网站 | 国产一区二区在线观看视频 | 一级毛片aaaaaa免费看 | 亚洲欧美成人 | 国产一级一片免费播放i | 日韩午夜精品 | 欧美二级在线观看免费 | 成人免费观看高清在线毛片 | 成人精品一区二区www | 九九久久精品国产 | 99久久综合狠狠综合久久一区 | 在线a国产| 九九色视频在线观看 | 国产精品一区二区av | 国产亚洲网站 |