首页 > 其他分享 >mongos集群部署

mongos集群部署

时间:2022-09-07 14:12:30浏览次数:66  
标签:部署 mongodb true 集群 mongos conf 172.16 data

mongos 分片服务器
https://blog.csdn.net/weixin_49724150/article/details/121748365

1.部署的服务器ip地址
    172.16.0.151
    172.16.0.173
    172.16.0.220

2.etcd版本
    wget  https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-5.0.4.tgz
3.三台服务器安装目录 
  3个数据分片副本集,1个mongos副本集,1个config副本集
  /data  安装目录
  /data01到/data05
    /data01/share1  #数据分片副本集1目录
    /data02/share2  #数据分片副本集2目录
    /data03/share3  #数据分片副本集3目录
    /data04/configsvr #config副本集目录
    /data05/mongos   #mongos副本集目录


4.每个内存限制0.5G;
[root@im-04 ~]# ls /data/mongodb/conf/
configsvr.conf  mongos.conf  shard1.conf  shard2.conf  shard3.conf

[root@im-04 conf]# vim shard1.conf 
systemLog:
    destination: file
    logAppend: true
    path: /data02/mongodb/logs/shard2.log
storage:
    dbPath: /data02/mongodb/data
    journal:
      enabled: true
    wiredTiger:
      engineConfig:
        configString : cache_size=500M
processManagement:
    fork: true
    pidFilePath: /data02/mongodb/shard2/shard2.pid
net:
   port: 27020
   bindIp: 0.0.0.0
replication:
   replSetName: shard2
sharding:
   clusterRole: shardsvr
   
   
[root@im-04 conf]# vim shard2.conf 
systemLog:
    destination: file
    logAppend: true
    path: /data03/mongodb/logs/shard3.log
storage:
    dbPath: /data03/mongodb/data
    journal:
       enabled: true
    wiredTiger:
      engineConfig:
        configString : cache_size=500M
processManagement:
    fork: true
    pidFilePath: /data03/mongodb/shard3/shard3.pid
net:
    port: 27021
    bindIp: 0.0.0.0
replication:
    replSetName: shard3
sharding:
    clusterRole: shardsvr
[root@im-04 conf]# vim shard1.conf     
systemLog:
    destination: file
    logAppend: true
    path: /data01/mongodb/logs/shard1.log
storage:
    dbPath: /data01/mongodb/data
    journal:
      enabled: true
    wiredTiger:
      engineConfig:
        configString : cache_size=500M
processManagement:
    fork: true
    pidFilePath: /data01/mongodb/shard1/shard1.pid
net:       
   port: 27019
   bindIp: 0.0.0.0
replication:
   replSetName: shard1
sharding:
   clusterRole: shardsvr



[root@im-04 conf]# cat configsvr.conf 
systemLog:
    destination: file
    logAppend: true
    path: /data04/mongodb/logs/configsvr.log

# Where and how to store data.
storage:
    dbPath: /data04/mongodb/data
    journal:
      enabled: true

# how the process runs
processManagement:
    fork: true  # fork and run in background
    pidFilePath: /data04/mongodb/configsvr/configsvr.pid  # location of pidfile
 
# network interfaces
net:
    port: 27018
    bindIp: 0.0.0.0
sharding:
    clusterRole: configsvr

replication:
    replSetName: config

        
[root@im-04 conf]# cat mongos.conf 
systemLog:
  destination: file
  logAppend: true
  path: /data05/mongodb/logs/mongos.log
processManagement:
  fork: true
  pidFilePath: /data05/mongodb/mongos/mongos.pid
net:
  port: 27017
  bindIp: 0.0.0.0
sharding:
  configDB: config/172.16.0.151:27018,172.16.0.173:27018,172.16.0.220:27018



5.创建mongodb启动用户
    groupadd mongod
    useradd -g mongod mongod

6.配置mongodb目录权限
    chown -R mongod:mongod /data/mongodb

7.启动
    /data/mongodb/bin/mongod -f /data/mongodb/conf/configsvr.conf
    /data/mongodb/bin/mongod   -f /data/mongodb/conf/shard1.conf
    /data/mongodb/bin/mongod   -f /data/mongodb/conf/shard2.conf
    /data/mongodb/bin/mongod   -f /data/mongodb/conf/shard3.conf
    /data/mongodb/bin/mongos -f /data/mongodb/conf/mongos.conf


8.登录任意一台配置服务器,初始化配置副本集

    #连接
    mongo 172.16.0.151 --port 27018
    初始化configServer副本集
    rs.initiate(
      {
        _id: "config",
        configsvr: true,
        members: [
          { _id : 0, host : "172.16.0.151:27018" },
          { _id : 1, host : "172.16.0.173:27018" },
          { _id : 2, host : "172.16.0.220:27018" }
        ]
      }
    )
    查看节点状态
    rs.status()

    启动三台服务器的shard1 server
    /data/mongodb/bin/mongod   -f /data/mongodb/conf/shard1.conf

    mongo 172.16.0.151 --port 27020
    rs.initiate(
      {
        _id: "shard2",
        members: [
          { _id : 0, host : "172.16.0.151:27020" },
          { _id : 1, host : "172.16.0.173:27020" },
          { _id : 2, host : "172.16.0.220:27020" }
        ]
      }
    )

    mongo 172.16.0.173 --port 27021
    rs.initiate(
      {
        _id: "shard3",
        members: [
          { _id : 0, host : "172.16.0.173:27021" },
          { _id : 1, host : "172.16.0.151:27021" },
          { _id : 2, host : "172.16.0.220:27021" }
        ]
      }
    )


9、启用分片

    mongo 172.16.0.220 --port 27017
    sh.addShard( "shard1/172.16.0.151:27019,172.16.0.173:27019,172.16.0.220:27019")
    sh.addShard( "shard2/172.16.0.151:27020,172.16.0.173:27020,172.16.0.220:27020")
    sh.addShard( "shard3/172.16.0.151:27021,172.16.0.173:27021,172.16.0.220:27021")


这个命令可以查看MongoDB的内存限制情况,查看结果如下:
 
    SECONDARY> db.hostInfo()

        wiredTiger:
          engineConfig:
            configString : cache_size=500M
            
        

 

标签:部署,mongodb,true,集群,mongos,conf,172.16,data
From: https://www.cnblogs.com/zxqblogrecord/p/16665210.html

相关文章

  • zookeeper集群部署
    1.部署的服务器ip地址172.16.0.151172.16.0.173172.16.0.2202.zookeeper版本wgethttps://mirrors.bfsu.edu.cn/apache/zookeeper/zookeeper-3.7.1/ap......
  • Ceph集群应用基础-CephFS文件存储
    在mgr1上安装ceph-mds服务,可以和其他服务器混用(如ceph-mon、ceph-mgr)root@mgr1:~#apt-cachemadisonceph-mdsroot@mgr1:~#aptinstallceph-md=16.2.10-1bionic把mgr......
  • redis 集群安装
    1.前期准备安装ruby升级ruby参见前一篇前期准备#EPEL源安装ruby支持yuminstallrubyrubygems-y使用国内源gemsource-ahttp://mirrors.aliyun.com/rubyge......
  • Ceph集群应用基础-RGW对象存储
    部署radodgw服务,将mgr服务器部署为RGW主机aptinstallradosgw=16.2.10-1bionicceph-deploy--overwrite-confrgwcreatemgr1 直接浏览器访问,能访问到说明启动成功......
  • Ceph集群应用基础-块存储RBD
    块存储RBD基础创建RBD创建存储池,制定pg和pgp的数量,pgp是对存在于pg的数据进行组合存储,pgp通常等于pg的值cephosdpoolcreatemyrbd16464对存储池启用RBD功能ceph......
  • 利用docker-compose快速搭建kafka集群
    一、安装docker-compose工具安装docker-compose事先需要安装docker,这里需要自行安装#升级pippip3install--upgradepip#指定docker-compose版本安装pipinst......
  • 通过IIS部署Flask项目
      本文主要介绍在WindowsServer2012R2上通过IIS部署Flask项目的过程,以及对TTFB延迟大问题的思考。关于如何申请云服务器,注册(子)域名,备案,开放云服务器端口,获取SSL证书......
  • 使用 Azure 应用服务部署 React App
    使用Azure应用服务部署ReactApp大家好,今天我们将讨论如何将生产就绪的React应用程序部署到Azure云。对于今天的任务,如果您没有帐户,我们需要创建一个azure帐户和......
  • Heroku 不再免费了,我还能如何部署我的 React/Node 应用程序? :(
    Heroku不再免费了,我还能如何部署我的React/Node应用程序?......
  • [安装配置] SpringBoot项目部署
    打包SpringBoot项目 部署方式一:手动部署1、将打包好的jar包上传到Linux服务器中mkdir-p/opt/java62/app2、前台启动SpringBoot应用编译jar包:java-jarhellowor......