Here, I will discuss how to create mongo shard in the single machine (locally) for dev environment. My OS is Linux Mint and MongoDB version is 4+. Install MongoDB: I downloaded mongodb tar files and extracted it to the /opt/mongo/. Create database directory: $mkdir -p /opt/mongo_db/shard_db I like /opt directory very much, if you do not like create your database directory in /opt, please create it in your desire location. I dislike pointless argument. To create shard you must have a plan to organize your shard clusters. In this example, I will create 3 shard each shard will have 2 replicate sets and 1 config server with 2 replicate sets and 1 mongos to connect shard cluster via config server 1) Shard servers/clusters 1.1) Create sdb directory inside the shard_db/ directory: $mkdir sdb 1.2) Inside sdb/ directory we are going to create 6 directories as I mentioned earlier that I am going to create 3 shard with 2 re...