Skip to content

Scripts for creating and testing a simple MongoDB Sharded Cluster on a single Linux host machine/VM

License

Notifications You must be signed in to change notification settings

pkdone/mongo-multi-svr-generator

Repository files navigation

Scripts for creating and testing a MongoDB Sharded Cluster on a single Linux host machine/VM

Introduction

Automates the configuring/running of a quick and dirty, self contained, replicated and sharded MongoDB environment on a local Linux host machine, to help a user explore these features - not to be used for real production environments.

By default, creates an environment containing the following 11 server processes, listening on different local ports:

          --REPLICA-0 mongod
    SHARD0--REPLICA-1 mongod
          --REPLICA-2 mongod

          --REPLICA-0 mongod
    SHARD1--REPLICA-1 mongod
          --REPLICA-2 mongod

          --CONFIG-SVR-1 mongod
    CONFIG--CONFIG-SVR-2 mongod
          --CONFIG-SVR-3 mongod

          --MONGOS-SVR-0 mongos
    ROUTER
          --MONGOS-SVR-1 mongos

Pre-Requisites

  • Tested on Linux only (Ubuntu 14.04 & 16.04 x86-64 - other Linux variants should be fine). Mac OS X hosts may be ok too, but haven't tested.
  • Requires recent version on MongoDB (eg. 3.2.x, 3.4.x or 3.6) already installed on the local machine - versions earlier than 3.2 are not supported due to the project's use of the preferred modern way to configure a "config db" as a "Config Server Replica Set", which is not supported in earlier versions.

Usage Steps

  1. In this root directory, modify file 'localenv' to reflect the local settings required

  2. From the terminal, run the following to delete and re-create the directories to hold Mongo server data files and logs (also kills any mongod/mongos processes that happen to be running on the local machine):

    $ ./1_rebuild_target_directories.sh
    
  3. From the terminal, run the following to configure and start the servers with replication and sharding (this takes a few minutes when first run, if not using "smallfiles", whilst mongod server initialises its data files)

    $ ./2_start_servers.sh
    
  4. OPTIONAL From the terminal, run the following to insert lots of small randomly generated documents into the sharded collection, using a small range of values for the shard key

    $ ./3_inject_docs.sh
    

You should now be able to connect to one of the mongos processes, using the Mongo Shell, and run sh.status() to view the status of the cluster.

About

Scripts for creating and testing a simple MongoDB Sharded Cluster on a single Linux host machine/VM

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published