Question

I am learning Mongodb and it has been a fun experience so far. Now I am working with around 3-4 collections which have over 6million records each, and I am trying to see if I could horizontal scale that into shards. Just so you all know, I am just trying to learn Mongodb, and the environment that I have is a 64bit - ubuntu system.

I only have one system, so I am trying to understand if I can create shards of the database that I have locally. I honestly do not understand the concept of sharding yet. But I wanted to know if I could create many shards on a single dev system.

I tried looking for resources online, but I haven't found any yet. Any help with this would be awesome.

Était-ce utile?

La solution

You certainly can if you run all of your shards on different ports and with different db directories. So you can do

mongod --port 27020 --dbpath /var/db/shard1
mongod --port 27021 --dbpath /var/db/shard2 
mongod --port 27022 --dbpath /var/db/shard3 

and so on.

Then you can connect to your shardsvr instance through mongos and enter sh.addShard( "localhost:27020" ) and so on to add your shards.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top