• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
懒惰虫
博客园    首页    新随笔    联系   管理    订阅  订阅

Replica Set + sharding搭建mongodb集群

先上几个用到的yaml文件,以后有时间了再更新,我是借鉴的https://blog.csdn.net/zeroctu/article/details/71082168,本人按照上面的搭建,是可行的,不过一定要注意搭建的mongodb版本,不要选3.2,如果要用 sharding,一定要选用3.4以上版本,不然分片无效。

 

systemLog:
  destination: file
  path: "/usr/local/mongodb/instance/mongos/log/mongos.log"
net:
  port: 27017
processManagement: 
  fork: true
sharding: 
  configDB: cfgSet/10.74.20.40:27019,10.74.20.14:27019,10.74.20.13:27019

 

cfg = {
 _id: "shard01",
 members:[
 {
  _id: 0,
  host: "10.74.20.40:27018",
  priority: 3
 },
 {
  _id: 1,
  host: "10.74.20.14:27018",
  priority: 2
 },
 {
  _id: 2,
  host: "10.74.20.13:27018",
  arbiterOnly: true
 }
 ]
}

 

cfg = {
 _id: "shard02",
 members:[
 {
  _id: 0,
  host: "10.74.20.40:27118",
  arbiterOnly: true
 },
 {
  _id: 1,
  host: "10.74.20.14:27118",
  priority: 3
 },
 {
  _id: 2,
  host: "10.74.20.13:27118",
  priority: 2
 }
 ]
}

 

cfg = {
 _id: "shard03",
 members:[
 {
  _id: 0,
  host: "10.74.20.40:27218",
  priority: 2
 },
 {
  _id: 1,
  host: "10.74.20.14:27218",
  arbiterOnly: true
 },
 {
  _id: 2,
  host: "10.74.20.13:27218",
  priority: 3
 }
 ]
}

 

 

cfg = 
{
 _id: "cfgSet",
 configsvr: true,
 members:[
 {
  _id: 0,
  host: "10.74.20.40:27019",
  priority: 3
 },
 {
  _id: 1,
  host: "10.74.20.14:27019",
  priority: 2
 },
 {
  _id: 2,
  host: "10.74.20.13:27019",
  priority: 1
 }
 ]
}

 

 

db.runCommand({addshard:"shard01/10.74.20.40:27018,10.74.20.14:27018,10.74.20.13:27018"})



db.runCommand({addshard:"shard02/10.74.20.40:27118,10.74.20.14:27118,10.74.20.13:27118"})



db.runCommand({addshard:"shard03/10.74.20.40:27218,10.74.20.14:27218,10.74.20.13:27218"})

 

posted @ 2018-09-04 16:07  懒惰虫  阅读(144)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3