-
-
Save sz3n/836987e01ca825faf0718bd7a6ed3ef4 to your computer and use it in GitHub Desktop.
Install MongoDB from source on Fedora/RedHat based Linux with SystemD
This file contains 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 | |
# MongoDB Version | |
MONGODB_VER='2.2.2' | |
# Get all the dependencies up to date | |
yum -y update | |
yum -y install scons gcc-c++ glibc-devel | |
# Get the source | |
cd /usr/local/src/ | |
wget http://downloads.mongodb.org/src/mongodb-src-r$MONGODB_VER.tar.gz | |
tar xfz mongodb-src-r$MONGODB_VER.tar.gz | |
cd mongodb-src-r$MONGODB_VER | |
# Compile and Install | |
scons all | |
scons install | |
# Create the SystemD dependant files | |
echo '[Unit] | |
Description=High-performance, schema-free document-oriented database | |
After=syslog.target network.target | |
[Service] | |
Type=forking | |
User=mongod | |
Group=mongod | |
PIDFile=/var/run/mongodb/mongod.pid | |
EnvironmentFile=/etc/sysconfig/mongod | |
ExecStart=/usr/local/bin/mongod $OPTIONS run | |
[Install] | |
WantedBy=multi-user.target' > /lib/systemd/system/mongod.service | |
echo 'OPTIONS="--quiet -f /etc/mongod.conf"' > /etc/sysconfig/mongod | |
# Setup the required user and group | |
useradd -r -U mongod | |
# Setup the required directories | |
mkdir -p /var/run/mongodb/ | |
mkdir -p /var/log/mongo/ | |
mkdir -p /var/lib/mongo/ | |
chown mongod:mongod /var/run/mongodb/ | |
chown mongod:mongod /var/log/mongo/ | |
chown mongod:mongod /var/lib/mongo/ | |
chmod 0755 /var/log/mongo/ | |
chmod 0755 /var/run/mongodb/ | |
chmod 0755 /var/lib/mongo | |
# Start the new service and enable it on boot | |
systemctl --system daemon-reload | |
systemctl start mongod.service | |
systemctl enable mongod.service |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment