Skip to content

Instantly share code, notes, and snippets.

@ksomemo
Created November 14, 2014 10:32
Show Gist options
  • Save ksomemo/625ebd53573964b83943 to your computer and use it in GitHub Desktop.
Save ksomemo/625ebd53573964b83943 to your computer and use it in GitHub Desktop.

MongoDB on EC2

EC2

Create the instance using the key pair and security group previously created and also include the --ebs-optimized flag and specify individual PIOPS EBS volumes (/dev/xvdf for data, /dev/xvdg for journal, /dev/xvdh for log). Refer to the documentation for ec2-run-instances for more information on devices and parameters.:

data/journal/log

Next, create/configure the mount points, mount each volume, set ownership (MongoDB runs under the mongod user/group), and set the /journal link:

sudo mkdir /data /log /journal
sudo mkfs.ext4 /dev/xvdf # for data
sudo mkfs.ext4 /dev/xvdg # for journal
sudo mkfs.ext4 /dev/xvdh # for log
echo '/dev/xvdf /data ext4 defaults,auto,noatime,noexec 0 0
/dev/xvdg /journal ext4 defaults,auto,noatime,noexec 0 0
/dev/xvdh /log ext4 defaults,auto,noatime,noexec 0 0' | sudo tee -a /etc/fstab
sudo mount /data
sudo mount /journal
sudo mount /log
sudo chown mongod:mongod /data /journal /log
sudo ln -s /journal /data/journal

mongo config

sudovi /etc/mongod.conf
dbpath = /data
logpath = /log/mongod.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment