Skip to content

MongoDB: Replication+Sharding

tobami edited this page Sep 15, 2011 · 2 revisions

The most complicated setup are sharded replica sets. Let's assume we call our MongoDB cluster "webscale1", and want to deploy two shards, "shard1" and "shard2".

We would then assign the following roles and attributes to the nodes: MongoDB cluster diagram

webscale1_mongos

{
    "name": "webscale1_mongos",
    "default_attributes": {
        "mongodb": {
            "cluster_name": "webscale1",
            "sharded_collections": {
                "webscale1.items": "name"
            }
        }
    },
    "override_attributes": { },
    "json_class": "Chef::Role",
    "description": "webscale1 MongoDB mongos",
    "chef_type": "role",
    "run_list": [
        "recipe[mongodb::mongos]"
    ]
}

webscale1_config_server

{
    "name": "webscale1_configserver",
    "default_attributes": {
        "mongodb": {
            "cluster_name": "webscale1"
        }
    },
    "override_attributes": { },
    "json_class": "Chef::Role",
    "description": "webscale1 MongoDB configserver",
    "chef_type": "role",
    "run_list": [
        "recipe[mongodb::configserver]"
    ]
}

webscale1_shard

{
    "name": "webscale1_shard",
    "default_attributes": {
        "mongodb": {
            "cluster_name": "webscale1"
        }
    },
    "override_attributes": { },
    "json_class": "Chef::Role",
    "description": "webscale1 MongoDB shard",
    "chef_type": "role",
    "run_list": [
        "recipe[mongodb::shard]",
        "recipe[mongodb::replicaset]"
    ]
}
Clone this wiki locally