Skip to content

Instantly share code, notes, and snippets.

@ngsw
Created January 14, 2013 12:47
Show Gist options
  • Select an option

  • Save ngsw/4529844 to your computer and use it in GitHub Desktop.

Select an option

Save ngsw/4529844 to your computer and use it in GitHub Desktop.
ver="1.8.4"
mongodUID="27017"
mongodGID="27017"
wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-${ver}.tgz
tar zxvf mongodb-linux-x86_64-${ver}.tgz
mv mongodb-linux-x86_64-${ver} /usr/local/
cd /usr/local
ln -s mongodb-linux-x86_64-${ver} mongodb
mkdir /usr/local/mongodb/db
mkdir /var/log/mongo
mkdir /var/run/mongodb
groupadd -g ${mongodGID} mongod
useradd -u ${mongodUID} -g ${mongodGID} mongod
id mongod
# => uid=27017(mongod) gid=27017(mongod) groups=27017(mongod)
cat > /usr/local/mongodb/mongodb.conf <<'MONGOCONF.EOF'
logpath=/var/log/mongo/mongod.log
logappend=true
fork = true
rest = true
dbpath=/usr/local/mongodb/db
pidfilepath = /var/run/mongodb/mongod.pid
MONGOCONF.EOF
cat > /usr/local/mongodb/bin/startmongod.sh <<'STARTMONGO.EOF'
#!/bin/sh
/usr/local/mongodb/bin/mongod -f /usr/local/mongodb/mongodb.conf
STARTMONGO.EOF
cat > /usr/local/mongodb/bin/stopmongod.sh <<'STOPMONGO.EOF'
#!/bin/sh
source /etc/init.d/functions
killproc -p /var/run/mongodb/mongod.pid -d 300 /usr/local/mongodb/bin/mongodb
STOPMONGO.EOF
chmod +x /usr/local/mongodb/bin/{start,stop}mongod.sh
chown -R mongod:mongod /usr/local/mongodb-linux-x86_64-${ver}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment