How it works...
A key file is nothing but a regular file that contains a secret. MongoDB allows a key file to contain 6 to 1,024 characters. In our example, we begin by creating a key file using the openssl utility; in that, we use the parameters rand -base64 756 to generate a set of random sequence of 1,024 Base64 characters.
Next, in step 2, we use the chmod utility available in Unix to ensure that this newly created key file is not globally readable. The command chmod 400 <filename> strips all permissions from the file except read-only to the file owner.
In step 3, we start three instances of MongoDB replica set nodes, each listening on a different port and using a different --dbpath. In a more realistic scenario, you would probably be ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access