Creating Keyfile For MongoDB Replication Set

Creating a keyfile is one of the required steps while you are configuring a MongoDB replication set for a Sitecore solution. In this post I will mention Why and How you can generate a keyfile. This post is a smaller extract for my upcoming post mentioning about creation of MongoDB Replication Set for Sitecore.

WHY a keyfile is required?

In a replication set all the participants, Mongod instances should talk to each other (authenticate each other) by supplying a password for inter-process authentication. The content of the key file is the shared secret used for all internal authentication.

How to create keyfile?

In order to create a keyfile you need to have OpenSSL installed, below are the links to download it,

Once OpenSSL is installed, open command prompt and navigate to \OpenSSL-Win32\bin and execute below command,

[code language=”xml”]
openssl rand -base64 741 > mongodb-keyfile

This will generate the required keyfile in the bin folder as seen in below screen, you can now deploy this file on all the mongod instances which are participating in replication set.

MongoDB Replication Set Keyfile

As mentioned earlier in this post, I am preparing myself to write another post maybe over the weekend showing how to create a full functional MongoDB Replication Set for a Sitecore Solution..