zoukankan      html  css  js  c++  java
  • mongodb 3.2 分片部署步骤

    #linux 网络优化1. 文件中/etc/sysctl.conf, 加入
    net.core.somaxconn = 2048
    fs.file-max = 2000000
    fs.nr_open = 2000000
    net.ipv4.ip_local_port_range = 1024 65535

    • hard nofile 1000000
    • soft nofile 1000000
    2. 文件/etc/security/limits.conf中加入:
    • hard nproc 1000000
    • hard nproc 1000000

      3. mongo部分的优化
      echo never >/sys/kernel/mm/transparent_hugepage/enabled
      echo never > /sys/kernel/mm/transparent_hugepage/defrag

    1. disable senux
      /etc/selinux/config
      SELINUX=disabled
    1. 防火墙部分, 暂时停止firewalld
      firewall:
      systemctl start firewalld.service #启动firewall
      systemctl stop firewalld.service #停止firewall
      systemctl disable firewalld.service #禁止firewall开机启动
    1. mongodb 安装
      如果是解压安装, 默认放到 /tools
      1. 解压到
      /root/tools/mongodb
      cd /
      ln -s /root/tools

      2. 加入PATH
      vim /etc/profile
      export PATH=$PATH:/tools/mongodb/bin

      对于rpm包, 运行下面命令
      rpm -ivh *.rpm

    1. 配置mongodb
      mkdir /data/mongodb
      cd /data/mongodb
      mkdir db log

      常见配置文件, 并启动
      mongod --config configdb.conf

    =====================================
    https://docs.mongodb.org/manual/tutorial/deploy-shard-cluster/

    1. 配置说明 
      234机器上:
      shard0 192.168.1.234:27018
      shard1 192.168.1.234:27019 
      configsrv 192.168.1.234:30001
    1. 配置 configserver
      1. 文件配置的例子
      sharding:
      clusterRole: configsvr
      replication:
      replSetName: configReplSet
      net:
      port: <port>
      storage:
      dbpath: <path>

      2. 启动
      mongod --config configsrv1.conf
      非文件方式
      mongod --configsvr --replSet configReplSet --port <port> --dbpath <path>

    1. 初始化configserver, 这里配置两个 configure
      1. 进入mongo shell
      mongo 192.168.1.234:30001
      rs.initiate( {
      _id: "configReplSet",
      configsvr: true,
      members: [ { _id: 0, host: "192.168.1.55:30001" }, { _id: 1, host: "192.168.1.234:30001" }
      ]
      } )

      2. 查看状态
      rs.status()

    2. start mongos
      //mongos --configdb configReplSet/192.168.1.55:30001,192.168.1.234:30001 --port 37017&
      mongos --configdb configRS/192.168.1.234:30001 --port 37017 --logappend --logpath /data/mongodb/log/route.log&
    1. connect to mongos
      mongo --host 192.168.1.234 --port 37017
    1. add sharding
      1. 建立实例
      mkdir db2 db3
      修改对应的配置文件
      Note: 这个地方需要设置最大内存
      ulimit -v 10000000 修改最大虚拟地址空间为10G 
      --wiredTigerCacheSizeGB 5

      2. 加入分片
      // sh.addShard( "rs1/192.168.1.234:27018" ) // add a shard for a replica set named rs1 
      sh.addShard( "192.168.1.234:27018" )
      sh.addShard( "192.168.1.234:27019" )

      3. 激活分片
      sh.enableSharding("<database>") // db.runCommand( { enableSharding: <database> } )
      sh.enableSharding("mydb")

      4. 查看状态
      sh.status()

    #########################
    插入前的准备
    sh.enableSharding("<database>") // db.runCommand( { enableSharding: <database> } )
    sh.enableSharding("gwgps")

    db.location.ensureIndex({"hostid":1})
    db.location.ensureIndex({"posTime":1})

    sh.shardCollection("gwgps.location", { "hostid": 1})

  • 相关阅读:
    关于J2SE/Jsp/Sping/Hibernate/Struts2的视频下载
    JQuery插件之图片轮播插件–slideBox
    javascript学习-创建json对象数据,遍历
    MD5算法原理
    【Linux】linux经常使用基本命令
    藏书阁(非技术流书籍)
    搭建自己的SIPserver:开源sipserveropensips的搭建及终端TwInkle的使用
    linux下仅仅有rman备份集的异机不同文件夹恢复
    URAL 1684. Jack&#39;s Last Word KMP
    javabean总结
  • 原文地址:https://www.cnblogs.com/myibm/p/5939328.html
Copyright © 2011-2022 走看看