wiki/info/landscape/creating-ec2-mongodb-image-from-scratch.md
... ...
@@ -0,0 +1,88 @@
1
+Start with an Amazon Linux 2 AMI (HVM), SSD Volume Type - ami-0fad7378adf284ce0 (64-bit x86) image.
2
+
3
+Add the yum repository for MongoDB 3.6 by creating ``/etc/yum.repos.d/mongodb-org-3.6.repo`` as follow:
4
+
5
+```
6
+[mongodb-org-3.6]
7
+name=MongoDB Repository
8
+baseurl=https://repo.mongodb.org/yum/amazon/2013.03/mongodb-org/3.6/x86_64/
9
+gpgcheck=1
10
+enabled=1
11
+gpgkey=https://www.mongodb.org/static/pgp/server-3.6.asc
12
+```
13
+
14
+Then:
15
+
16
+```
17
+yum install -y mongodb-org-server mongodb-org-mongos mongodb-org-shell mongodb-org-tools
18
+mkfs.xfs /dev/nvme0n1
19
+mount /dev/nvme0n1 /var/lib/mongo
20
+```
21
+
22
+In file ``/etc/mongod.conf`` comment the line
23
+```
24
+# bindIp: 127.0.0.1 # Listen to local interface only, comment to listen on all interfaces.
25
+```
26
+
27
+so that MongoDB listens on all interfaces, not only localhost. Furthermore, set the ``directoryPerDB`` property to ``true`` and provide a replication set name using the ``replication.replSetName`` property.
28
+
29
+Here is the full ``/etc/mongod.conf`` file:
30
+
31
+```
32
+# mongod.conf
33
+
34
+# for documentation of all options, see:
35
+# http://docs.mongodb.org/manual/reference/configuration-options/
36
+
37
+# where to write logging data.
38
+systemLog:
39
+ destination: file
40
+ logAppend: true
41
+ path: /var/log/mongodb/mongod.log
42
+
43
+# Where and how to store data.
44
+storage:
45
+ dbPath: /var/lib/mongo
46
+ journal:
47
+ enabled: true
48
+ directoryPerDB: true
49
+# engine:
50
+# mmapv1:
51
+# wiredTiger:
52
+
53
+# how the process runs
54
+processManagement:
55
+ fork: true # fork and run in background
56
+ pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile
57
+ timeZoneInfo: /usr/share/zoneinfo
58
+
59
+# network interfaces
60
+net:
61
+ port: 27017
62
+# bindIp: 127.0.0.1 # Listen to local interface only, comment to listen on all interfaces.
63
+
64
+
65
+#security:
66
+
67
+#operationProfiling:
68
+
69
+replication:
70
+ replSetName: live
71
+
72
+#sharding:
73
+
74
+## Enterprise-Only Options
75
+
76
+#auditLog:
77
+
78
+#snmp:
79
+```
80
+
81
+Before being able to start the mongod service, more configuration is required:
82
+
83
+```
84
+chown mongod /var/lib/mongo/
85
+chgrp mongod /var/lib/mongo/
86
+```
87
+
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