Created
February 27, 2019 10:22
-
-
Save hakanilter/32fe8aa871a32013f16bfd86199f4286 to your computer and use it in GitHub Desktop.
Amazon Linux Single Node Simple MongoDB Setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Update packages | |
sudo yum update -y | |
# Mount EBS volume | |
sudo mkfs -t xfs /dev/xvdb | |
sudo mkdir /data | |
sudo mount /dev/xvdb /data | |
# Install MongoDB | |
echo ' | |
[mongodb-org-4.0] | |
name=MongoDB Repository | |
baseurl=https://repo.mongodb.org/yum/amazon/2013.03/mongodb-org/4.0/x86_64/ | |
gpgcheck=1 | |
enabled=1 | |
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc | |
' > mongodb-org-4.0.repo | |
sudo mv mongodb-org-4.0.repo /etc/yum.repos.d/ | |
sudo yum install -y mongodb-org | |
# Create configuration file | |
echo ' | |
# mongod.conf | |
systemLog: | |
destination: file | |
logAppend: true | |
path: /data/mongodb/log/mongod.log | |
storage: | |
dbPath: /data/mongodb/data | |
journal: | |
enabled: true | |
processManagement: | |
fork: true # fork and run in background | |
pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile | |
timeZoneInfo: /usr/share/zoneinfo | |
net: | |
port: 27017 | |
bindIp: 0.0.0.0 | |
' > mongod.conf | |
sudo mv mongod.conf /etc/mongod.conf | |
# Create directories | |
sudo mkdir /data/mongodb | |
sudo mkdir /data/mongodb/log | |
sudo mkdir /data/mongodb/data | |
sudo chown -R mongod:mongod /data/mongodb | |
# Set ulimit | |
sudo echo "mongod soft nproc 64000" >> /etc/security/limits.conf | |
# Start MongoDB | |
sudo service mongod start | |
sudo chkconfig mongod on |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment