wiki/info/landscape/creating-ec2-mongodb-image-from-scratch.md
... ...
@@ -1,3 +1,7 @@
1
+# Setting up an EC2 Image for a MongoDB Replica Set from Scratch
2
+
3
+## Image and Basic Packages
4
+
1 5
Start with an Amazon Linux 2 AMI (HVM), SSD Volume Type - ami-0fad7378adf284ce0 (64-bit x86) image.
2 6
3 7
Add the yum repository for MongoDB 3.6 by creating ``/etc/yum.repos.d/mongodb-org-3.6.repo`` as follow:
... ...
@@ -19,6 +23,8 @@ mkfs.xfs /dev/nvme0n1
19 23
mount /dev/nvme0n1 /var/lib/mongo
20 24
```
21 25
26
+## MongoDB Set-Up
27
+
22 28
In file ``/etc/mongod.conf`` comment the line
23 29
```
24 30
# bindIp: 127.0.0.1 # Listen to local interface only, comment to listen on all interfaces.
... ...
@@ -85,4 +91,8 @@ chown mongod /var/lib/mongo/
85 91
chgrp mongod /var/lib/mongo/
86 92
```
87 93
88
-will change the ownerships of the directory mounted from ephemeral storage accordingly, so the MongoDB daemon can write to it. The execute ``systemctl start mongod.service`` to launch the MongoDB process.
... ...
\ No newline at end of file
0
+will change the ownerships of the directory mounted from ephemeral storage accordingly, so the MongoDB daemon can write to it. The execute ``systemctl start mongod.service`` to launch the MongoDB process.
1
+
2
+## MongoDB Replica Set Configuration
3
+
4
+Connect to the MongoDB on that instance, then issue the command ``rs.initiate()`` in order to turn the instance into the "seed" of a replica set. You can then, for the time being, ``quit()`` the mongo shell. Re-connecting, e.g., with ``mongo "mongodb://localhost:27017/?replicaSet=live"``, will show the ``PRIMARY`` of the new replica set.
... ...
\ No newline at end of file