-
-
Save tacaswell/6f7df75d1a5e8d874f1ea9c779f061ae to your computer and use it in GitHub Desktop.
Installing MongoDB on Ubuntu 15.04
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
#!/bin/sh | |
## | |
## Bash install script for mongo 3.2 for Ubuntu 15.04, because of | |
## the replacement of upstart with systemd | |
## | |
## - AUTHOR: Alexandru Budurovici <https://w0rldart.com> | |
## - VERSION: 1.0 | |
## | |
# Make sure we're running with root permissions | |
if [ "$(id -u)" != "0" ]; then | |
echo "This script must be run as root" 1>&2 | |
exit 1 | |
fi | |
# Install Mongo | |
# https://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/ | |
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927 | |
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-3.2.list | |
apt-get update | |
apt-get install -y mongodb-org | |
# Create the SystemD dependant files | |
echo '[Unit] | |
Description=High-performance, schema-free document-oriented database | |
After=syslog.target | |
After=network.target | |
[Service] | |
# Type=forking | |
# User=mongodb | |
# Group=mongodb | |
# PermissionsStartOnly=true | |
# PIDFile=/var/run/mongodb.pid | |
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf | |
[Install] | |
WantedBy=multi-user.target' > /lib/systemd/system/mongod.service | |
# Anticipate to the log issue | |
touch /var/log/mongodb/mongod.log | |
chown -R mongodb:mongodb /var/log/mongodb/ | |
# Start the new service and enable it on boot | |
systemctl daemon-reload | |
systemctl enable mongod.service | |
systemctl start mongod.service |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment