• Needs RAM and Disk I/O mongod • Stateless request router • Lives on your app server • Minimal data needs mongos • Metadata server for sharded configura4ons • Minimal data needs • 64-‐bit instances config
or Extra Large (typical) – Hi-‐Memory: XL, XXL or 4XL (large data sets) – Cluster instances provide increased capacity and bandwith • mongos – Deploy onto your app server (32 or 64-‐bit) • config – Standard instances – Micro instance is sufficient
/dev/md0p1! Partition device and make filesystem $ sudo mkdir /data! $ sudo chown `id -u` /data! Create mount point and set ownership $ sudo echo ‘/dev/md0p1 /data auto noatime,noexec,nodiratime 0 0’ >> /etc/fstab! $ sudo mount –a /dev/md0p1 /data! Update the filesystem table and mount
Set the dbpath $ sudo chkconfig mongod on! $ sudo /etc/init.d/mongod start! Set to autostart at boot and start the server now $ mongo! MongoDB shell version: 2.0.2! connecting to: test! >! Connect to MongoDB
connecting to: test! >! Connect to MongoDB > rs.initiate()! {! "info2" : "no configuration explicitly specified -- making one",! "me" : "ip-10-127-127-91:27017",! "info" : "Config now saved locally. Should come online in about a minute.",! "ok" : 1! }! Initialize the replica set > rs.add(“ec2-abc.def.amazonaws.com”)! { “ok” : 1 }! Add each replica set member external DNS name
SECONDARY> db.runCommand({fsync:1,lock:1});! {! "info" : "now locked against writes, use db.$cmd.sys.unlock.findOne() to unlock",! "ok" : 1! }! Lock the database $ ec2-create-snapshot vol-1234abcd --description "MongoDB RAID backup1"! volume descrip4on Create a snapshot for each attached volume $ mdadm --detail /dev/md0p1! Run mdadm and note the UUID
$ ec2-attach-volume vol-1234abcd -i i-aa3bc4c8 -d /dev/sdh1! Create and attach a volume from each snapshot $ sudo mdadm --assemble --auto-update-homehost -u 07552c4d…a9c2f2fc --no-degraded /dev/md0! mdadm: /dev/md0 has been started with 4 drives.! Reassemble the RAID $ sudo mkdir /data2! $ sudo chown `id -u` /data2! Create mount point and set ownership UUID from mdadm
when using replica4on – Doesn’t block on the primary – Secondary updates once unlocked • Use mongodump to backup live data – Collec4ons, databases, everything – Restore with mongorestore
paper: hnp://www.10gen.com/white-‐papers • Amazon EC2 info at MongoDB wiki: hnp://www.mongodb.org/display/DOCS/Amazon+EC2 • Scripts for working with EBS (crea4ng, anaching, etc.): hnps://gist.github.com/1482182