MongoDB and Amazon Web Services - LinuxFestNorthWest
Slides from my talk on deploying MongoDB on Amazon Web Services. Includes production tips and information on sample AWS CloudFormation templates that can be used to automate MongoDB deployments.
groups – Instance sizes – Storage needed now and later • Configure filesystem as ext4 or XFS • Reduce I/O overhead • Raise file descriptor limits • Set read-‐ahead
vg0 /dev/md0! $ sudo lvcreate -n data vg0! $ sudo mkfs.ext4 /dev/vg0/data! Partition device and make filesystem $ sudo mkdir /data! $ sudo chown mongod:mongod /data! Create mount point and set ownership $ echo ‘/dev/vg0/data /data ext4 defaults,auto,noatime,noexec 0 0’ | sudo tee –a /etc/fstab! $ sudo mount /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.4! 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
to create and manage AWS resources • Create text-‐based templates which describe resources in your stack • Templates are JSON and can be managed like code or stored in S3
EBS volumes in a RAID10 • Replica set – Each node similar to single node – Primary configured in “parent” template – Secondary configured in “child” template – MulCple secondaries are created/referenced in “parent” template
region) • New security group – Port 22: open to all – Port 27017: open to instances in group • IAM resource • 4 EBS volumes • 4 EBS volume aiachments • 10-‐minute Cmeout for the whole thing
• Add addiConal “ReplicaSetMember” instances • Update “replicaSetConfigInit.js” • Spread across mulCple zones – Note: spreading across regions may require addiConal edits and/or manual inputs
hip://www.mongodb.org/display/DOCS/AutomaCng +Deployment+with+CloudFormaCon • Amazon EC2 info (incl. in-‐depth guide): hip://www.mongodb.org/display/DOCS/Amazon+EC2 • MongoDB AMI on AWS Marketplace hips://aws.amazon.com/marketplace/pp/B007IBMJPI/ • MongoDB on Amazon Web Services white paper: hip://www.10gen.com/white-‐papers