Implementing configuration servers
Now it's time to start the first part of sharding. Establishing a configuration server is as easy as running a mongod
instance using the --configsvr
parameter.
The following scheme shows the structure of the command:
mongod --configsvr --dbpath <path> --port <port>
If you don't pass the dbpath
or port
parameters, the configuration server uses /data/configdb
as the path to store data and port 27019
to execute the instance. However, you can override the default values using the preceding command.
If this is the first time that you have run the configuration server, you might be faced with some issues due to the existence of dbpath
. Before running the configuration server, make sure that you have created the path; otherwise, you will see an error as shown in the following screenshot:
You can simply create the directory using the mkdir
command as shown in the following line of command:
mkdir /data/configdb
Also, make sure that you are executing the...