好湿?好紧?好多水好爽自慰,久久久噜久噜久久综合,成人做爰A片免费看黄冈,机机对机机30分钟无遮挡

主頁 > 知識庫 > MongoDB搭建高可用集群的完整步驟(3個分片+3個副本)

MongoDB搭建高可用集群的完整步驟(3個分片+3個副本)

熱門標簽:青白江400企業電話申請 外呼線路資源屬于電信業務嗎 長沙電銷外呼防封卡是什么 小裙科技電銷機器人怎樣 crm外呼系統聯系方式 內蒙古營銷智能外呼系統哪個好 呼和浩特外呼系統原理是什么 河南電話外呼系統招商 智能外呼系統官網

配置腳本以及目錄下載:點我下載

一、規劃好端口ip

    架構圖如下,任意抽取每個副本集中的一個分片(非仲裁節點)可以組成一份完整的數據。

    1. 第一個副本集rs1

share1 10.0.0.7:30011:/data/share_rs/share_rs1/share1/data/
share2 10.0.0.7:40011:/data/share_rs/share_rs1/share2/data/
share3 10.0.0.7:50011:/data/share_rs/share_rs1/share3/data/

    2. 第二個副本集rs2

share1 10.0.0.7:30012:/data/share_rs/share_rs2/share1/data/
share2 10.0.0.7:40012:/data/share_rs/share_rs2/share2/data/
share3 10.0.0.7:50012:/data/share_rs/share_rs2/share3/data/

    3. 第三個副本集rs3

share1 10.0.0.7:30013:/data/share_rs/share_rs3/share1/data/
share2 10.0.0.7:40013:/data/share_rs/share_rs3/share2/data/
share3 10.0.0.7:50013:/data/share_rs/share_rs3/share3/data/

    4.config server

config1 10.0.0.7:30002:/data/share_rs/config/config1/data/
config2 10.0.0.7:30002:/data/share_rs/config/config2/data/
config3 10.0.0.7:30002:/data/share_rs/config/config3/data/

    5. mongos

mongos1 10.0.0.7:30001:/data/share_rs/mongos/mongos1/data/
mongos2 10.0.0.7:30001:/data/share_rs/mongos/mongos2/data/
mongos3 10.0.0.7:30001:/data/share_rs/mongos/mongos3/data/

二、創建相應的目錄

mkdir -p /data/share_rs/{share_rs1,share_rs2,share_rs3}/{share1,share2,share3}/{data,log}
mkdir -p /data/share_rs/mongos/{mongos1,mongos2,mongos3}/{data,log}
mkdir -p /data/share_rs/config/{config1,config2,config3}/{data,log}

三、配置mongs和config的配置文件(其他副本參考修改端口以及ip)

[mongo@mongo config1]$ cat mongo.conf
dbpath=/data/share_rs/config/config1/data/
logpath=/data/share_rs/config/config1/log/mongo.log
logappend=true
port=30002
fork=true
rest=true
httpinterface=true
configsvr=true

[mongo@mongo mongs1]$ cat mongo.conf 
logpath=/data/share_rs/mongos/mongos1/log/mongo.log
logappend=true
port=30001
fork=true
configdb=10.0.0.7:30002,10.0.0.7:40002,10.0.0.7:50002
chunkSize=1

四、依次啟動三個副本上的config服務器以及mongs服務器

mongod -f /data/share_rs/config/config1/mongo.conf
mongod -f /data/share_rs/config/config2/mongo.conf
mongod -f /data/share_rs/config/config3/mongo.conf

mongos -f /data/share_rs/mongos/mongos1/mongo.conf
mongos -f /data/share_rs/mongos/mongos2/mongo.conf
mongos -f /data/share_rs/mongos/mongos3/mongo.conf

五、配置mong分片的的配置文件(其他副本參考修改端口以及ip),同一個分片的副本集名稱一樣,即replSet。

第一個副本集的一個分片
[mongo@mongo share_rs1]$ cat share1/mongo.conf
dbpath=/data/share_rs/share_rs1/share1/data
logpath=/data/share_rs/share_rs1/share1/log/mongo.log
logappend=true
port=30011
fork=true
rest=true
httpinterface=true
replSet=rs1
shardsvr=true

第二個副本集的一個分片
[mongo@mongo share_rs2]$ cat share1/mongo.conf
dbpath=/data/share_rs/share_rs2/share1/data
logpath=/data/share_rs/share_rs2/share1/log/mongo.log
logappend=true
port=30012
fork=true
rest=true
httpinterface=true
replSet=rs2
shardsvr=true

第三個副本集的一個分片
[mongo@mongo share_rs1]$ cat share1/mongo.conf
dbpath=/data/share_rs/share_rs3/share1/data
logpath=/data/share_rs/share_rs3/share1/log/mongo.log
logappend=true
port=30013
fork=true
rest=true
httpinterface=true
replSet=rs3
shardsvr=true

六、啟動各個分片以及相應的副本

mongod -f /data/share_rs/share_rs1/share1/mongo.conf
mongod -f /data/share_rs/share_rs1/share2/mongo.conf
mongod -f /data/share_rs/share_rs1/share3/mongo.conf
mongod -f /data/share_rs/share_rs2/share1/mongo.conf
mongod -f /data/share_rs/share_rs2/share2/mongo.conf
mongod -f /data/share_rs/share_rs2/share3/mongo.conf
mongod -f /data/share_rs/share_rs3/share1/mongo.conf
mongod -f /data/share_rs/share_rs3/share2/mongo.conf
mongod -f /data/share_rs/share_rs3/share3/mongo.conf

[mongo@mongo share_rs]$ ps -ef | grep mongo | grep share | grep -v grep
mongo  2480  1 0 12:50 ?  00:00:03 mongod -f /data/share_rs/share_rs1/share1/mongo.conf
mongo  2506  1 0 12:50 ?  00:00:03 mongod -f /data/share_rs/share_rs1/share2/mongo.conf
mongo  2532  1 0 12:50 ?  00:00:02 mongod -f /data/share_rs/share_rs1/share3/mongo.conf
mongo  2558  1 0 12:50 ?  00:00:03 mongod -f /data/share_rs/share_rs2/share1/mongo.conf
mongo  2584  1 0 12:50 ?  00:00:03 mongod -f /data/share_rs/share_rs2/share2/mongo.conf
mongo  2610  1 0 12:50 ?  00:00:02 mongod -f /data/share_rs/share_rs2/share3/mongo.conf
mongo  2636  1 0 12:50 ?  00:00:01 mongod -f /data/share_rs/share_rs3/share1/mongo.conf
mongo  2662  1 0 12:50 ?  00:00:01 mongod -f /data/share_rs/share_rs3/share2/mongo.conf
mongo  2688  1 0 12:50 ?  00:00:01 mongod -f /data/share_rs/share_rs3/share3/mongo.conf
mongo  3469  1 0 13:17 ?  00:00:00 mongod -f /data/share_rs/config/config1/mongo.conf
mongo  3485  1 0 13:17 ?  00:00:00 mongod -f /data/share_rs/config/config2/mongo.conf
mongo  3513  1 0 13:17 ?  00:00:00 mongod -f /data/share_rs/config/config3/mongo.conf
mongo  3535  1 0 13:18 ?  00:00:00 mongos -f /data/share_rs/mongos/mongos1/mongo.conf
mongo  3629  1 0 13:22 ?  00:00:00 mongos -f /data/share_rs/mongos/mongos2/mongo.conf
mongo  3678  1 0 13:22 ?  00:00:00 mongos -f /data/share_rs/mongos/mongos3/mongo.conf

七、設置副本集

1.登錄第一個副本的一個分片,為其設置副本集
mongo 127.0.0.1:30011/admin
config = { _id:"rs1", members:[
      {_id:0,host:"10.0.0.7:30011"},
      {_id:1,host:"10.0.0.7:40011"},
      {_id:2,host:"10.0.0.7:50011",arbiterOnly:true}
    ]
   }

-- >; 注意:這里id rs1 需要與副本集中的名稱一樣即replSet的值
rs.initiate(config)
{ "ok" : 1 } -- >; 提示這個說明初始化成功
 
2.登錄第二個副本的一個分片,為其設置副本集

mongo 127.0.0.1:30012/admin
config = { _id:"rs2", members:[
      {_id:0,host:"10.0.0.7:30012"},
      {_id:1,host:"10.0.0.7:40012"},
      {_id:2,host:"10.0.0.7:50012",arbiterOnly:true}
    ]
   }
rs.initiate(config)
{ "ok" : 1 } -- >; 提示這個說明初始化成功

3.登錄第三個副本的一個分片,為其設置副本集

mongo 127.0.0.1:30013/admin
config = { _id:"rs3", members:[
      {_id:0,host:"10.0.0.7:30013"},
      {_id:1,host:"10.0.0.7:40013"},
      {_id:2,host:"10.0.0.7:50013",arbiterOnly:true}
    ]
   }
rs.initiate(config)
{ "ok" : 1 } -- >; 提示這個說明初始化成功

八、目前前搭建了mongodb配置服務器、路由服務器,各個分片服務器,不過應用程序連接mongos 路由服務器并不能使用分片機制,還需要在程序里設置分片配置,讓分片生效。

連接到第一個mongos上
mongo 10.0.0.7:30001/admin
db.runCommand({addshard:"rs1/10.0.0.7:30011,10.0.0.7:40011,10.0.0.7:50011",allowLocal:true}); 
db.runCommand({addshard:"rs2/10.0.0.7:30012,10.0.0.7:40012,10.0.0.7:50012"});
db.runCommand({addshard:"rs3/10.0.0.7:30013,10.0.0.7:40013,10.0.0.7:50013"});
 
-- >; 將第一個分片的所有副本全部加入
-- >; 如里shard是單臺服務器,用 db.runCommand( { addshard : "[: ]" } )這樣的命令加入
-- >; 如果shard是副本集,用db.runCommand( { addshard : "replicaSetName/[:port][,serverhostname2[:port],…]" });這樣的格式表示.

mongos>; sh.status()
--- Sharding Status ---
 sharding version: {
  "_id" : 1,
  "minCompatibleVersion" : 5,
  "currentVersion" : 6,
  "clusterId" : ObjectId("57f33f4d35d9c494714adfa7")
}
 shards:
  { "_id" : "rs1", "host" : "rs1/10.0.0.7:30011,10.0.0.7:40011" }
  { "_id" : "rs2", "host" : "rs2/10.0.0.7:30012,10.0.0.7:40012" }
  { "_id" : "rs3", "host" : "rs3/10.0.0.7:30013,10.0.0.7:40013" }
 active mongoses:
  "3.2.7" : 3
 balancer:
  Currently enabled: yes
  Currently running: no
  Failed balancer rounds in last 5 attempts: 0
  Migration Results for the last 24 hours:
    No recent migrations
 databases:

九、將集合進行分片。

db.runCommand({enablesharding:"testcol"});
-- >; 指定testdb分片生效

db.runCommand({shardcollection: "testcol.testdoc",key : {id: 1} } )
-- >; 指定數據庫里需要分片的集合和片鍵

-->; 插入測試數據
for (var i = 1; i ;= 100000; i++){ db.testdoc.save({id:i,"name":"harvey"})}; -- >; 查看該集合的狀態
db.testcol.stats();

總結

以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作具有一定的參考學習價值,謝謝大家對腳本之家的支持。

您可能感興趣的文章:
  • 如何為MongoDB添加分片副本集
  • 分布式文檔存儲數據庫之MongoDB分片集群的問題
  • Mongodb副本集和分片示例詳解
  • MongoDB分片集群部署詳解
  • MongoDB分片在部署與維護管理中常見的事項總結大全
  • 詳解MongoDB4.0構建分布式分片群集
  • MongoDB分片鍵的選擇和案例實例詳解
  • MongoDB分片詳解
  • mongodb分片技術_動力節點Java學院整理
  • mongodb3.4集群搭建實戰之高可用的分片+副本集
  • 深入理解MongoDB分片的管理
  • Mongodb 刪除添加分片與非分片表維護
  • MongoDB 主分片(primary shard)相關總結

標簽:舟山 池州 楚雄 安順 呼倫貝爾 白山 黃石 菏澤

巨人網絡通訊聲明:本文標題《MongoDB搭建高可用集群的完整步驟(3個分片+3個副本)》,本文關鍵詞  MongoDB,搭建,高可用,高,可用,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《MongoDB搭建高可用集群的完整步驟(3個分片+3個副本)》相關的同類信息!
  • 本頁收集關于MongoDB搭建高可用集群的完整步驟(3個分片+3個副本)的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 337P粉嫩大胆噜噜噜噜69影视| 主人啊灬啊别停灬用力啊视频| 亚洲之爱| 欧美XXXXZ0oZ| 国产日产欧产精品| 狠狠干天天操| 把女人弄爽特黄a大片视频| 古代级a毛片免费观看中字| 天码毛片一区二区三区入口 | 曰批视频免费40分钟| 刘玥91精品一区二区三区| 日韩不卡一二三区| 久久久久久精品免费啪啪国卢 | 国产乱理伦片在线看夜| 蜜臀导航| 肉动漫在线播放免费高清| 女人扒开屁股爽桶30分钟麻豆| 国产午夜福利片国产一级A片小说| 掀开岳裙子从后面挺进去| 乡村乱婬1第60部分| 美女扒开尿口给男人桶动态图| 人獸交videostube极品| 精品国产一级久久A片性麻豆| 撕开她的乳罩慢慢揉捏动漫| 蜜桃视频成人| 人人揉人人添人人捏人人看| 老师美女被黄动漫免费观看| 男人狂躁进女人免费视频| 白丝女班长被弄得娇喘不停| 韩国仑乱电影大全| japanese丝袜老师xxx| 被男人臊得嗷嗷叫的姿势视频| 成人??视频免费观看网站| 黄色在线资源| GOGO大胆日本无码裸体艺术| 美女扒开粉嫩尿囗给男生桶的作文 | 包臀裙女教师波多野结衣| 精品亚洲一区二区蜜桃| 欧美片婬乱一级A片金苹果| 成人a大片高清在线观看| 女人被躁到高潮免费视频网站95|