MongoDB 3.2 Shard Deployment steps

Source: Internet
Author: User
Tags mongo shell

#linux Network optimization 1. File in/etc/sysctl.conf, join
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. Optimization of the MONGO section
      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. Firewall section, temporarily stop FIREWALLD
      Firewall
      Systemctl Start Firewalld.service #启动firewall
      Systemctl Stop Firewalld.service #停止firewall
      Systemctl Disable Firewalld.service #禁止firewall开机启动
    1. MongoDB Installation
      If the decompression is installed, the default is put to/tools
      1. Unzip to
      /root/tools/mongodb
      CD/
      Ln-s/root/tools

      2. Join path
      Vim/etc/profile
      Export path= $PATH:/tools/mongodb/bin

      For RPM packages, run the following command
      RPM-IVH *.rpm

    1. Configure MongoDB
      Mkdir/data/mongodb
      Cd/data/mongodb
      mkdir DB Log

      Common configuration file and start
      Mongod--config configdb.conf

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

    1. Configuration Instructions
      234 on the machine:
      Shard0 192.168.1.234:27018
      Shard1 192.168.1.234:27019
      Configsrv 192.168.1.234:30001
    1. Configure Configserver
      1. Examples of file configurations
      Sharding:
      Clusterrole:configsvr
      Replication
      Replsetname:configreplset
      Net
      Port: <port>
      Storage
      DBPath: <path>

      2. Start
      Mongod--config configsrv1.conf
      Non-file mode
      Mongod--configsvr--replset configreplset--port <port>--dbpath <path>

    1. Initialize Configserver, configure two configure here
      1. Enter 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. View status
      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. Create an example
      mkdir DB2 DB3
      Modify the corresponding configuration file
      Note: This place needs to set the maximum memory
      Ulimit-v 10000000 Modify maximum virtual address space to 10G
      --WIREDTIGERCACHESIZEGB 5

      2. Adding shards
      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. Activating shards
      Sh.enablesharding ("<database>")//Db.runcommand ({enablesharding: <database>})
      Sh.enablesharding ("MyDB")

      4. View status
      Sh.status ()

#########################
Pre-insertion Preparation
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})

MongoDB 3.2 Shard Deployment steps

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.