SlideShare a Scribd company logo
MongoDB Sharding Cluster Installation Guide
Version                   Author                                   Abstract                                                  Release date

0.1                       Philip zhong                             Draft                                                     2012-07-09




      Deployment Architecture ................................................................................................................... 2

      Prepare Servers ................................................................................................................................. 2
Deployment Architecture




        Prepare Servers

Shard Name   Primary Instance server   Second Instance server   Mongos Server         Config Server
Shard1       10.224.56.105:27017       null                     10.224.56.105:30000   10.224.57.165:20000
Shard2       10.224.56.106:27017       null                     10.224.56.106:30000   10.224.57.165:20000
Shard3       10.224.56.107:27017       null                     10.224.56.107:30000   10.224.57.165:20000
Shard4       10.224.56.108:27017       null                     10.224.56.108:30000   10.224.57.165:20000
Shard5       10.224.56.109:27017       null                     10.224.56.109:30000   10.224.57.165:20000
Shard6       10.224.56.110:27017       null                     10.224.56.110:30000   10.224.57.165:20000
Shard7       10.224.56.111:27017       null                     10.224.56.111:30000   10.224.57.165:20000
Shard8       10.224.56.112:27017       null                     10.224.56.112:30000   10.224.57.165:20000
Shard9       10.224.56.113:27017       null                     10.224.56.113:30000   10.224.57.165:20000
Shard10      10.224.56.114:27017       null                     10.224.56.114:30000   10.224.57.165:20000


        *Notice:

         1. You can install Mongos to another single server.
2. You can use three config servers to improve the High availability.

3. You can install three replica set to improve the High availability.

1. Install Primary/secondary Instance program on every shard
   instance server.
  Please refer to << MongoDB_Program_Installation_Guide.doc>>

  #su - root

  # mkdir -p /data/mongo

  # mkdir -p /var/log/mongo/

  # chown -R mongodb:mongodb            /data/mongo

  # chown -R mongodb:mongodb /var/log/mongo

  # mkdir -p      /data/mongo/shard1/

  #numactl --interleave=all /opt/mongodb206/bin/mongod --shardsvr --replSet shard1 --port
  27017 --dbpath /data/mongo/shard1 --oplogSize 100 --logpath /var/log/mongo/mongod.log --
  logappend --fork --journal



  * Notice:

  1. You can change it by you install directory.

  2. If you have secondary replica set, you can start primary replica set with nojournal

2. Initiate MongoDB replica set on every shard instance server.
  # /opt/mongodb206/bin/mongo

    >config = {_id: 'shard1' , members:

       [

              {_id: 0, host: '10.224.56.105:27017'}

       ]

      }

       >rs.initiate(config)
* Notice:

    1. If you want to add secondary replica set, you can add the server and port into Initiation.

3. Install config program on config server
   Please refer to << MongoDB_Program_Installation_Guide.doc>>

    #su - mongodb

    # mkdir -p /data/mongo/config

    # numactl --interleave=all /opt/mongodb206/bin/mongod --configsvr --dbpath
/data/mongo/config --port 20000 --logpath /data/mongo/config/config.log --logappend --fork

4. Install mongos program on every shard mongos server
   If mongos server and mongoDB instance are not in same server, please refer to <<
   MongoDB_Program_Installation_Guide.doc >>

   #su -root

   # mkdir -p /var/log/mongo/

   # chown -R mongodb:mongodb /var/log/mongo

   #su - mongodb

   #/opt/mongodb206/bin/mongos --configdb 10.224.57.165:20000 --port 30000 --chunkSize
   1000 --logpath /var/log/mongo/mongos.log --logappend –fork



5. Configure Shard Cluster
   Login one mongos server, For example:

   #/opt/mongodb206/bin/mongo 10.224.56.114:30000/admin

   >db.runCommand ({addshard:"shard1/10.224.56.105:27017",name:"s1",maxsize:20480});

   >db.runCommand({addshard:"shard2/10.224.56.106:27017",name:"s2",maxsize:20480});

   >db.runCommand({addshard:"shard3/10.224.56.107:27017",name:"s3",maxsize:20480});

   >db.runCommand({addshard:"shard4/10.224.56.108:27017",name:"s4",maxsize:20480});

   >db.runCommand({addshard:"shard5/10.224.56.109:27017",name:"s5",maxsize:20480});

   >db.runCommand({addshard:"shard6/10.224.56.110:27017",name:"s6",maxsize:20480});
>db.runCommand({addshard:"shard7/10.224.56.111:27017",name:"s7",maxsize:20480});

>db.runCommand({addshard:"shard8/10.224.56.112:27017",name:"s8",maxsize:20480});

>db.runCommand({addshard:"shard9/10.224.56.113:27017",name:"s9",maxsize:20480});

>db.runCommand({addshard:"shard10/10.224.56.114:27017",name:"s10",maxsize:20480});

>db.runCommand({listshards : 1 })

>db.runCommand( { enablesharding : "<dbname>" } );

>db.runCommand( { shardcollection : "<dbname.collection>" , key : { "keyname" : 1 } }



For example:

>db.runCommand({enablesharding :"feeddb"})

>db.runCommand( { shardcollection : "feeddb.test" , key : { "username" : 1 } } );

for (var x=97; x<97+26; x+=3){

      var y=(97+25);

      var prefix = String.fromCharCode(x) + String.fromCharCode(y);

      db.runCommand( { split :"feeddb.test", middle : {username : prefix } } );

  }
6. Trouble shooting
  #on testing ENV, you need turn off firewall and then you need restart the mongo programs.

  #/etc/init.d/iptables status

  #/etc/init.d/iptables stop

  #/etc/init.d/iptables status

  #chkconfig iptables off

7. Install Monitor program
  ???

More Related Content

What's hot (20)

PDF
How to train your L3DSR with PBR - MEMO -
Naoto MATSUMOTO
 
PDF
Creación de máquinas virtuales basada en kernel usando qemu y virsh
Jonathan Franchesco Torres Baca
 
PDF
Solaris 11 base box for Vagrant using Packer
Alan Chalmers
 
PDF
MAASとJujuでつくるOpenStack環境構築入門 IceHouse対応版 - OpenStack最新情報セミナー 2014年10月
VirtualTech Japan Inc.
 
PDF
JavaScript, Meet Cloud : Node.js on Windows Azure
Shiju Varghese
 
PDF
How to Install Ghost (CMS) MEMO
Naoto MATSUMOTO
 
DOC
Disk suit 4 setup and installation
ppratish
 
PDF
How to ride a 100GbE LAN -MEMO-
Naoto MATSUMOTO
 
PDF
Openstack kilo installation using rdo
Narasimha sreeram
 
PDF
Dev ops
Tom Hall
 
DOCX
MongoDB 3.2.0 Released
codeandyou forums
 
PDF
Openstack installation using rdo
Narasimha sreeram
 
PPTX
How to make a WoW server Warlords of Draenor
Mohit Maheshwari
 
PDF
How to make multi-boot USB drive for LiveCD iso images on EFI/UEFI and BIOS
Kentaro Hatori
 
DOCX
Fortinet SSL VPN access
Naseem Khoodoruth
 
PDF
Openstack installation using rdo multi node
Narasimha sreeram
 
PPTX
Mac osx snow leopard 10
sketchout
 
PPTX
Installing OpenStack Juno using RDO on RHEL
openstackstl
 
DOCX
Virtual box installation
Niranjan Pandey
 
PDF
A3 sec -_msr_2.0
a3sec
 
How to train your L3DSR with PBR - MEMO -
Naoto MATSUMOTO
 
Creación de máquinas virtuales basada en kernel usando qemu y virsh
Jonathan Franchesco Torres Baca
 
Solaris 11 base box for Vagrant using Packer
Alan Chalmers
 
MAASとJujuでつくるOpenStack環境構築入門 IceHouse対応版 - OpenStack最新情報セミナー 2014年10月
VirtualTech Japan Inc.
 
JavaScript, Meet Cloud : Node.js on Windows Azure
Shiju Varghese
 
How to Install Ghost (CMS) MEMO
Naoto MATSUMOTO
 
Disk suit 4 setup and installation
ppratish
 
How to ride a 100GbE LAN -MEMO-
Naoto MATSUMOTO
 
Openstack kilo installation using rdo
Narasimha sreeram
 
Dev ops
Tom Hall
 
MongoDB 3.2.0 Released
codeandyou forums
 
Openstack installation using rdo
Narasimha sreeram
 
How to make a WoW server Warlords of Draenor
Mohit Maheshwari
 
How to make multi-boot USB drive for LiveCD iso images on EFI/UEFI and BIOS
Kentaro Hatori
 
Fortinet SSL VPN access
Naseem Khoodoruth
 
Openstack installation using rdo multi node
Narasimha sreeram
 
Mac osx snow leopard 10
sketchout
 
Installing OpenStack Juno using RDO on RHEL
openstackstl
 
Virtual box installation
Niranjan Pandey
 
A3 sec -_msr_2.0
a3sec
 

Viewers also liked (20)

PPS
唯一一隻登上時代雜誌封面的狗狗
Fa Zhou Shi
 
PDF
Presentació del diccionari grec clàssic català
Equip de Clàssiques de l'ICE de la UAB
 
PPTX
Grammar book
raquel63485
 
PDF
Terugblik en resultatenoverzicht 2010
Mieke Sanden, van der
 
PPT
Diseño de panalería, indumentaria 2012
Diseño Dos Indumentaria
 
PDF
PNY Power Bank Series for Smart Devices
PNY Technologies Asia Pacific Limited
 
PDF
My MSc. Project
Abhijit Mondal
 
PDF
Pm 02 track1-- 魏刚--osac-trusted-computing-pools-in-folsom-v2
OpenCity Community
 
PDF
Putting the WOW into your School's WOM, ADVIS Presentation
Rick Newberry
 
PPTX
Am 04 track1--salvatore orlando--openstack-apac-2012-final
OpenCity Community
 
PDF
Hp cloud performance_benchmark
OpenCity Community
 
PPT
Multiple Intelligences in the Classroom by Carol Levensaler, CSU, Chico
Tanya Madjarova
 
PDF
Wiggins & Poulton: Malawi Farm Input Supply Scheme
futureagricultures
 
PDF
Eksamensbeviser fra RUC og Copenhagen Business School
Johnny Grenzlikowski
 
PPTX
Assets models seminar
Michael Shepherd
 
PDF
То, что вы хотели знать о HandlerSocket, но не смогли нагуглить
Sergey Xek
 
PPTX
Anti Hypertensives- pharmacology
Beenish Bhutta
 
PPTX
Ливоблисс Надежная защита Вашей печени
Елена Шальнова
 
PPTX
Juveline Crime in Bulgaria
Tanya Madjarova
 
DOCX
Biography
prateekshakya
 
唯一一隻登上時代雜誌封面的狗狗
Fa Zhou Shi
 
Presentació del diccionari grec clàssic català
Equip de Clàssiques de l'ICE de la UAB
 
Grammar book
raquel63485
 
Terugblik en resultatenoverzicht 2010
Mieke Sanden, van der
 
Diseño de panalería, indumentaria 2012
Diseño Dos Indumentaria
 
PNY Power Bank Series for Smart Devices
PNY Technologies Asia Pacific Limited
 
My MSc. Project
Abhijit Mondal
 
Pm 02 track1-- 魏刚--osac-trusted-computing-pools-in-folsom-v2
OpenCity Community
 
Putting the WOW into your School's WOM, ADVIS Presentation
Rick Newberry
 
Am 04 track1--salvatore orlando--openstack-apac-2012-final
OpenCity Community
 
Hp cloud performance_benchmark
OpenCity Community
 
Multiple Intelligences in the Classroom by Carol Levensaler, CSU, Chico
Tanya Madjarova
 
Wiggins & Poulton: Malawi Farm Input Supply Scheme
futureagricultures
 
Eksamensbeviser fra RUC og Copenhagen Business School
Johnny Grenzlikowski
 
Assets models seminar
Michael Shepherd
 
То, что вы хотели знать о HandlerSocket, но не смогли нагуглить
Sergey Xek
 
Anti Hypertensives- pharmacology
Beenish Bhutta
 
Ливоблисс Надежная защита Вашей печени
Елена Шальнова
 
Juveline Crime in Bulgaria
Tanya Madjarova
 
Biography
prateekshakya
 
Ad

Similar to Mongo db sharding_cluster_installation_guide (20)

PDF
Pandora FMS: MongoDB plugin
Pandora FMS
 
PDF
Setting up mongodb sharded cluster in 30 minutes
Sudheer Kondla
 
PDF
Setting up mongo replica set
Sudheer Kondla
 
PDF
Percona Cluster Installation with High Availability
Ram Gautam
 
PDF
How to Become Cloud Backup Provider
Cloudian
 
PDF
Install nagios
hassandb
 
PDF
Install nagios
hassandb
 
PDF
Install nagios
hassandb
 
PDF
How to become cloud backup provider with Cloudian HyperStore and CloudBerry L...
Cloudian
 
PDF
Mongo db reference manual
Deysi Gmarra
 
PDF
Mongo db reference-manual
Dan Llimpe
 
PDF
MongoDB Shard Cluster
Anuchit Chalothorn
 
PDF
Swift configurator installation-manual
Pramod Sharma
 
PDF
How to become cloud backup provider
CLOUDIAN KK
 
PDF
Mdb dn 2016_09_34_features
Daniel M. Farrell
 
PPTX
MongoDB – Sharded cluster tutorial - Percona Europe 2017
Antonios Giannopoulos
 
PPTX
MongoDB - Sharded Cluster Tutorial
Jason Terpko
 
PPTX
Sharded cluster tutorial
Antonios Giannopoulos
 
PDF
dachnug51 - HCL Sametime 12 as a Software Appliance.pdf
DNUG e.V.
 
PDF
MongoDB Replication Cluster
Anuchit Chalothorn
 
Pandora FMS: MongoDB plugin
Pandora FMS
 
Setting up mongodb sharded cluster in 30 minutes
Sudheer Kondla
 
Setting up mongo replica set
Sudheer Kondla
 
Percona Cluster Installation with High Availability
Ram Gautam
 
How to Become Cloud Backup Provider
Cloudian
 
Install nagios
hassandb
 
Install nagios
hassandb
 
Install nagios
hassandb
 
How to become cloud backup provider with Cloudian HyperStore and CloudBerry L...
Cloudian
 
Mongo db reference manual
Deysi Gmarra
 
Mongo db reference-manual
Dan Llimpe
 
MongoDB Shard Cluster
Anuchit Chalothorn
 
Swift configurator installation-manual
Pramod Sharma
 
How to become cloud backup provider
CLOUDIAN KK
 
Mdb dn 2016_09_34_features
Daniel M. Farrell
 
MongoDB – Sharded cluster tutorial - Percona Europe 2017
Antonios Giannopoulos
 
MongoDB - Sharded Cluster Tutorial
Jason Terpko
 
Sharded cluster tutorial
Antonios Giannopoulos
 
dachnug51 - HCL Sametime 12 as a Software Appliance.pdf
DNUG e.V.
 
MongoDB Replication Cluster
Anuchit Chalothorn
 
Ad

More from Philip Zhong (13)

PPTX
Cisco Webex Distributed Framework and Data Store Design
Philip Zhong
 
PPTX
How to Implement Distributed Data Store
Philip Zhong
 
PPT
MongoDB Knowledge Shareing
Philip Zhong
 
PPT
Adapter Poxy Pattern
Philip Zhong
 
PPTX
How to estimate_oracle_cost
Philip Zhong
 
PDF
Vitess percona 2012
Philip Zhong
 
PDF
Distributed_Database_System
Philip Zhong
 
PPTX
Mysql performance tuning
Philip Zhong
 
PPTX
Mysql5.1 character set testing
Philip Zhong
 
PPTX
How to write_language_compiler
Philip Zhong
 
PPTX
Compare mysql5.1.50 mysql5.5.8
Philip Zhong
 
PPTX
Mysql handle socket
Philip Zhong
 
PPTX
Mysql architecture&parameters
Philip Zhong
 
Cisco Webex Distributed Framework and Data Store Design
Philip Zhong
 
How to Implement Distributed Data Store
Philip Zhong
 
MongoDB Knowledge Shareing
Philip Zhong
 
Adapter Poxy Pattern
Philip Zhong
 
How to estimate_oracle_cost
Philip Zhong
 
Vitess percona 2012
Philip Zhong
 
Distributed_Database_System
Philip Zhong
 
Mysql performance tuning
Philip Zhong
 
Mysql5.1 character set testing
Philip Zhong
 
How to write_language_compiler
Philip Zhong
 
Compare mysql5.1.50 mysql5.5.8
Philip Zhong
 
Mysql handle socket
Philip Zhong
 
Mysql architecture&parameters
Philip Zhong
 

Mongo db sharding_cluster_installation_guide

  • 1. MongoDB Sharding Cluster Installation Guide Version Author Abstract Release date 0.1 Philip zhong Draft 2012-07-09 Deployment Architecture ................................................................................................................... 2 Prepare Servers ................................................................................................................................. 2
  • 2. Deployment Architecture Prepare Servers Shard Name Primary Instance server Second Instance server Mongos Server Config Server Shard1 10.224.56.105:27017 null 10.224.56.105:30000 10.224.57.165:20000 Shard2 10.224.56.106:27017 null 10.224.56.106:30000 10.224.57.165:20000 Shard3 10.224.56.107:27017 null 10.224.56.107:30000 10.224.57.165:20000 Shard4 10.224.56.108:27017 null 10.224.56.108:30000 10.224.57.165:20000 Shard5 10.224.56.109:27017 null 10.224.56.109:30000 10.224.57.165:20000 Shard6 10.224.56.110:27017 null 10.224.56.110:30000 10.224.57.165:20000 Shard7 10.224.56.111:27017 null 10.224.56.111:30000 10.224.57.165:20000 Shard8 10.224.56.112:27017 null 10.224.56.112:30000 10.224.57.165:20000 Shard9 10.224.56.113:27017 null 10.224.56.113:30000 10.224.57.165:20000 Shard10 10.224.56.114:27017 null 10.224.56.114:30000 10.224.57.165:20000 *Notice: 1. You can install Mongos to another single server.
  • 3. 2. You can use three config servers to improve the High availability. 3. You can install three replica set to improve the High availability. 1. Install Primary/secondary Instance program on every shard instance server. Please refer to << MongoDB_Program_Installation_Guide.doc>> #su - root # mkdir -p /data/mongo # mkdir -p /var/log/mongo/ # chown -R mongodb:mongodb /data/mongo # chown -R mongodb:mongodb /var/log/mongo # mkdir -p /data/mongo/shard1/ #numactl --interleave=all /opt/mongodb206/bin/mongod --shardsvr --replSet shard1 --port 27017 --dbpath /data/mongo/shard1 --oplogSize 100 --logpath /var/log/mongo/mongod.log -- logappend --fork --journal * Notice: 1. You can change it by you install directory. 2. If you have secondary replica set, you can start primary replica set with nojournal 2. Initiate MongoDB replica set on every shard instance server. # /opt/mongodb206/bin/mongo >config = {_id: 'shard1' , members: [ {_id: 0, host: '10.224.56.105:27017'} ] } >rs.initiate(config)
  • 4. * Notice: 1. If you want to add secondary replica set, you can add the server and port into Initiation. 3. Install config program on config server Please refer to << MongoDB_Program_Installation_Guide.doc>> #su - mongodb # mkdir -p /data/mongo/config # numactl --interleave=all /opt/mongodb206/bin/mongod --configsvr --dbpath /data/mongo/config --port 20000 --logpath /data/mongo/config/config.log --logappend --fork 4. Install mongos program on every shard mongos server If mongos server and mongoDB instance are not in same server, please refer to << MongoDB_Program_Installation_Guide.doc >> #su -root # mkdir -p /var/log/mongo/ # chown -R mongodb:mongodb /var/log/mongo #su - mongodb #/opt/mongodb206/bin/mongos --configdb 10.224.57.165:20000 --port 30000 --chunkSize 1000 --logpath /var/log/mongo/mongos.log --logappend –fork 5. Configure Shard Cluster Login one mongos server, For example: #/opt/mongodb206/bin/mongo 10.224.56.114:30000/admin >db.runCommand ({addshard:"shard1/10.224.56.105:27017",name:"s1",maxsize:20480}); >db.runCommand({addshard:"shard2/10.224.56.106:27017",name:"s2",maxsize:20480}); >db.runCommand({addshard:"shard3/10.224.56.107:27017",name:"s3",maxsize:20480}); >db.runCommand({addshard:"shard4/10.224.56.108:27017",name:"s4",maxsize:20480}); >db.runCommand({addshard:"shard5/10.224.56.109:27017",name:"s5",maxsize:20480}); >db.runCommand({addshard:"shard6/10.224.56.110:27017",name:"s6",maxsize:20480});
  • 5. >db.runCommand({addshard:"shard7/10.224.56.111:27017",name:"s7",maxsize:20480}); >db.runCommand({addshard:"shard8/10.224.56.112:27017",name:"s8",maxsize:20480}); >db.runCommand({addshard:"shard9/10.224.56.113:27017",name:"s9",maxsize:20480}); >db.runCommand({addshard:"shard10/10.224.56.114:27017",name:"s10",maxsize:20480}); >db.runCommand({listshards : 1 }) >db.runCommand( { enablesharding : "<dbname>" } ); >db.runCommand( { shardcollection : "<dbname.collection>" , key : { "keyname" : 1 } } For example: >db.runCommand({enablesharding :"feeddb"}) >db.runCommand( { shardcollection : "feeddb.test" , key : { "username" : 1 } } ); for (var x=97; x<97+26; x+=3){ var y=(97+25); var prefix = String.fromCharCode(x) + String.fromCharCode(y); db.runCommand( { split :"feeddb.test", middle : {username : prefix } } ); }
  • 6. 6. Trouble shooting #on testing ENV, you need turn off firewall and then you need restart the mongo programs. #/etc/init.d/iptables status #/etc/init.d/iptables stop #/etc/init.d/iptables status #chkconfig iptables off 7. Install Monitor program ???