Skip to content

MongoDB Sharding-01 -Directory Creations

    MongodDB clustering is one of major requirement when it comes to the production critical environments. It can be clustered as several ways including replica cluster, shard cluster, and here we are going to cluster it with shard clustering mechanism. This cluster type has several advance capabilities.

    • Ability to split data sets across multiple data nodes.
    • Ability to easy scale up/dow horizontally when it is required.

    In this scenario, we need to provision several servers together with mongoDB installed for configure the shard cluster.

    Steps to Set up MongoDB Sharding

    MongoDB Sharding can be set up by implementing the following steps:

    • Step 1: Creating a Directory for Config Server
    • Step 2: Starting MongoDB Instance in Configuration Mode
    • Step 3: Starting Mongos Instance
    • Step 4: Connecting to Mongos Instance
    • Step 5: Adding Servers to Clusters
    • Step 6: Enabling Sharding for Database
    Create Directories
    [root]# mkdir /var/lib/cfgsvr1 
    [root]#mkdir /var/lib/cfgsvr2 
    [root]#mkdir /var/lib/cfgsvr3
    Create Directories for 3 replicas of Shard 1
    [root]#mkdir /var/lib/replica11 
    [root]#mkdir /var/lib/replica12 
    [root]#mkdir /var/lib/replica13
    Create Directories for 3 replicas of Shard 2
    [root]#mkdir /var/lib/replica21 
    [root]#mkdir /var/lib/replica22 
    [root]#mkdir /var/lib/replica23
    Create Directories for 3 replicas of Shard 3
    [root]#mkdir /var/lib/replica31 
    [root]#mkdir /var/lib/replica32 
    [root]#mkdir /var/lib/replica33

    Leave a Reply