Manual Database Installation

This guide will cover the basic steps required for you to manually download and install the MongoDB Database. Note that it is possible for the Deadline Repository Installer to automatically download and install the database, but an internet connection is required. In addition, only specific operating systems are supported. If an internet connection isn’t available, or the current operating system you are using isn’t supported, you can follow this guide to install the Database manually.

Manually installing the MongoDB database might also be preferable for some because it gives you greater control over things like authentication, and allows you to create sharded clusters or replica sets for backup. More information on these advanced topics can be found at the bottom of this guide.

If you’re installing the MongoDB database on a machine running Linux or Mac OS X, you also have the option to download and install MongoDB through their associated package manager such as yum, apt, or homebrew. Just make sure the MongoDB version is 3.0.6 or later. For the purposes of this guide though, we will assume you’ve downloaded MongoDB manually.

Download and Install MongoDB

You can download the version of MongoDB that corresponds to your operating system from the MongoDB Downloads Page. Note that the MongoDB version must be 3.0.6 or later.

Once the download is finished, you’ll want to extract the compressed file (.tgz or .zip), rename the resulting folder to something readable (this guide will assume you chose application), and delete the compressed file. For example, mongodb-linux-x86_64-debian81.tgz decompresses to mongodb-linux-x86_64-debian81, and then can be renamed to application.

Next you’ll need to create a location to store the installation of the database. For the purpose of these instructions, we’re assuming these are the paths you’ll create:

  • Windows

    C:\DeadlineDatabase[VERSION]\mongo
    
  • Mac OS X

    /Applications/Thinkbox/DeadlineDatabase[VERSION]/mongo
    
  • Linux

    /opt/Thinkbox/DeadlineDatabase[VERSION]/mongo
    

Where [VERSION] is replaced with the major version of Deadline, such as 8. Follow this up by moving your application folder into this directory. Finally, create a data folder alongside the application folder.

Database Configuration

Before you run MongoDB, some configuration is required. First, a configuration file needs to be created, and then MongoDB should be configured to run as a service or daemon.

Configuration File (All Platforms)

A database configuration file has to be created in the data folder that you created above. For the purposes of this guide, this configuration file will be called config.conf. After creating the file, copy and paste the contents below into it. Before saving the file, be sure to make the following changes:

  • [PathToMongoDB] should be replaced with the path to the folder that contains the application and data folders you created earlier. If you’ve been following the instructions, that value will be C:\DeadlineDatabase[VERSION]\mongo, where [VERSION] is the major version of Deadline.
#MongoDB config file

#where to log
systemLog:
   destination: file
   path: [PathToMongoDB]/data/logs/log.txt
   quiet: true
   #verbosity: <integer>

#port for mongoDB to listen on
#uncomment below ipv6 and REST option to enable them.
net:
   port: 27080
   #ipv6: true
   #http:
         #RESTInterfaceEnabled: true

#where to store the data
storage:
 dbPath: [PathToMongoDB]/data

#enable sharding
#sharding:
   #clusterRole
   #configDB

#setup replica set with give replica set name
#replication:
   #replSetName

#enable authentication
#security:
   #authorization: enabled

These are the key settings defined in this file.

  • systemLog: path: This is where MongoDB will write its log to.
  • net: port: This is the port that MongoDB will listen on.
  • storage: dbPath: This is where MongoDB will save its data.

See the MongoDB Configuration File Options for more information on the available options. Note that if you change this file later, and MongoDB is already running, then you’ll need to restart the database service for the changes to go into effect.

Create Windows Service (Windows)

To have MongoDB run as a service on Windows, you’ll have to manually create the service. This can be done by launching a command prompt as an Administrator and running the following command. Before running the command, please make the following changes:

  • [VERSION] should be replaced with Deadline’s major version.
  • [PathToMongoInstall] should be replaced with the location of Deadline’s MongoDB folder. If you’ve been following the instructions, that value will be C:\DeadlineDatabase[VERSION]\mongo.
sc create Deadline[VERSION]DatabaseService binPath= "\"[PathToMongoInstall]\application\bin\mongod.exe\" --config \"[PathToMongoInstall]\data\config.conf\" --service" start= auto depend= TCPIP DisplayName= "Deadline [VERSION] Database Service"

Database Property List File (Mac OS X)

For Mac OS X, a plist file needs to be created to allow MongoDB to run as a daemon. For the purposes of this guide, this plist file will be called org.mongodb.mongod_Deadline[VERSION]DatabaseService.plist, where [VERSION] is the major version of Deadline. Create this file in a temporary location, and then copy and paste the contents below into it. Before saving the file, be sure to make the following changes:

  • [VERSION] should be replaced with Deadline’s major version.
  • [ReplaceWithServiceName] should be replaced with the name of the service. For example, Deadline[VERSION]DatabaseService.
  • [ReplaceWithMongoInstallPath] should be replaced with the path to Deadline’s MongoDB database. For example, /Applications/Thinkbox/DeadlineDatabase[VERSION].
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
  "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>org.mongodb.mongod_[ReplaceWithServiceName]</string>
  <key>ProgramArguments</key>
  <array>
        <string>[ReplaceWithMongoInstallPath]/mongo/application/bin/mongod</string>
        <string>run</string>
        <string>--config</string>
        <string>[ReplaceWithMongoInstallPath]/mongo/data/config.conf</string>
  </array>
  <key>RunAtLoad</key>
  <true/>
  <key>KeepAlive</key>
  <true/>
  <key>WorkingDirectory</key>
  <string>[ReplaceWithMongoInstallPath]/mongo/application/bin</string>
  <key>StandardErrorPath</key>
  <string>/var/log/mongo/output.txt</string>
  <key>StandardOutPath</key>
  <string>/var/log/mongo/output.txt</string>
  <key>HardResourceLimits</key>
  <dict>
        <key>NumberOfFiles</key>
        <integer>1024</integer>
  </dict>
  <key>SoftResourceLimits</key>
  <dict>
        <key>NumberOfFiles</key>
        <integer>1024</integer>
  </dict>
</dict>
</plist>

After saving the file, copy it to /Library/LaunchDaemons/.

Finally, the permissions will have to be set on the file to allow reading and writing, which can be done with the following command from a terminal. Before running the command, please make the following changes:

  • [VERSION] should be replaced with Deadline’s major version.
sudo chmod 644 /Library/LaunchDaemons/org.mongodb.mongod_Deadline[VERSION]DatabaseService.plist

Database Script File (Linux)

For Linux, an executable script file needs to be created to allow MongoDB to run as a service. For the purposes of this guide, this file will be called Deadline[VERSION]db, where [VERSION] is the major version of Deadline. Create this file in a temporary location, and then copy and paste the contents below into it. Before saving the file, be sure to make the following changes:

  • [VERSION] should be replaced with Deadline’s major version.
  • [PathToMongoDBBin] should be replaced with the path to MongoDB’s bin folder. Installer’s default path is /opt/Thinkbox/DeadlineDatabase[VERSION]/mongo/application/bin.
  • [PathToMongoDBData] should be replaced with the path to MongoDB’s data folder. Installer’s default path is /opt/Thinkbox/DeadlineDatabase[VERSION]/mongo/data.
#!/bin/bash
#
# mongodb Startup script for mongo DB
#
# chkconfig: - 20 80
# description: MongoDB (from "humongous") is a scalable, high-performance, open$

### BEGIN INIT INFO
# Provides: Deadline[VERSION]db
# Default-Start: 2 3 5
# Default-Stop:  0 1 4 6
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $network $local_fs $remote_fs
# Short-Description: Mongo DB NoSQL Database.
# Description: MongoDB (from "humongous") is a scalable, high-performance, open$
### END INIT INFO

# Source function library. (Supported only on Red Hat distributions.
( . /etc/rc.d/init.d/functions > /dev/null 2>&1 )

DEADLINEVERSION=[VERSION]
MONGODBBIN=[PathToMongoDBBin]
MONGODBDATA=[PathToMongoDBData]
MONGOSERVICEFILENAME="mongodb"
MONGOLOCK="/var/lock/subsys/deadline$DEADLINEVERSION$MONGOSERVICEFILENAME"
LOGFILE="/var/log/deadline$DEADLINEVERSION$MONGOSERVICEFILENAME.log"
PIDFILE="/var/run/deadline$DEADLINEVERSION$MONGOSERVICEFILENAME.pid"
RUNNING=0 # Is the process in our PID file running?
PID=-1    # What is the process ID?



check_running() {
        if [ -e "$PIDFILE" ]; then
                PID=`cat $PIDFILE`
                ps -p $PID &> /dev/null
                if [ $? -eq 0 ]; then
                        RUNNING=1
                else
                        RUNNING=0
                fi
        fi
}

start () {
        check_running
        if [ $RUNNING -eq 1 ]; then
                echo "MongoDB for Deadline $DEADLINEVERSION already running"
                echo
                exit 4
        else
                # Start mongod
                if [ -x "$MONGODBBIN/mongod" ]; then
                        ("$MONGODBBIN/mongod" --config "$MONGODBDATA/config.conf") &
                        echo $! > "$PIDFILE"
                        echo "MongoDB Started"
                        date "+%F %T: MongoDB Started" >> $LOGFILE
                        date "+%F %T: Full MongoDB log can be found in $MONGODBDATA/logs/log.txt" >> $LOGFILE

                        touch $MONGOLOCK 2> /dev/null

                        exit 0
                else
                        echo "Either mongod could not be found or could not be executed."
                        exit 1
                fi
        fi
}

stop () {
        check_running
        if [ $RUNNING -eq 1 ]; then
                echo "Shutting down MongoDB for Deadline $DEADLINEVERSION..."
                kill -QUIT $PID

                echo "MongoDB for Deadline $DEADLINEVERSION Stopped"
                date "+%F %T: MongoDB Stopped" >> $LOGFILE
                rm -rf "$PIDFILE"

                # Alright, it should actually be dead now, let init know.
                rm -f $MONGOLOCK

                exit 0
        else
                rm -rf "$PIDFILE"
                echo "MongoDB for Deadline $DEADLINEVERSION is not running"
                exit 7
        fi
}

restart() {
        check_running
        if [ $RUNNING -eq 1 ]; then
                echo "Shutting down MongoDB for Deadline $DEADLINEVERSION..."
                kill -QUIT $PID
                rm -rf "$PIDFILE"

                echo "MongoDB for Deadline $DEADLINEVERSION Stopped"
                date "+%F %T: MongoDB Stopped" >> $LOGFILE
        else
                rm -rf "$PIDFILE"
                echo "MongoDB for Deadline $DEADLINEVERSION is not running"
        fi

        start
}

reload() {
        restart
}

force_reload(){
        restart
}

rh_status(){
        check_running
        if [ $RUNNING -eq 1 ]; then
                echo "MongoDB for Deadline $DEADLINEVERSION is running as PID $PID."
                exit 0
        else
                echo "MongoDB for Deadline $DEADLINEVERSION is stopped."
                exit 3
        fi
}

rh_status_q(){
        rh_status > /dev/null 2>&1
}

# See how we were called.
case "$1" in
        start)
                $1
                ;;
        stop)
                $1
                ;;
        restart)
                $1
                ;;
        reload)
                rh_status_q || exit 7
                $1
                ;;
        force-reload)
                force_reload
                ;;
        status)
                rh_status
                ;;
        condrestart|try-restart)
                rh_status_q || exit 0
                restart
                ;;
        *)
                echo "Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
                exit 3
esac

After saving the file, copy it to /etc/init.d/.

Finally, the permissions will have to be set on the file to allow reading, writing, and execution, which can be done with the following command from a terminal. Before running the command, please make the following changes:

  • [VERSION] should be replaced with Deadline’s major version.
sudo chmod 755 /etc/init.d/Deadline[VERSION]db

Start Database Service

Now that MongoDB is installed and configured, it’s time is to start your MongoDB service or daemon. This can be done by executing the following command from a command prompt or terminal. Just replace [Version] with Deadline’s major version:

  • Windows (as Administrator):

    sc start Deadline[VERSION]DatabaseService
    
  • Mac OS X:

    launchctl load /Library/LaunchDaemons/org.mongodb_Deadline[VERSION]DatabaseService.plist
    
  • Linux:

    sudo service Deadline[VERSION]DatabaseService start
    

Confirm that MongoDB is Running

For the final step, you’ll want to confirm that the MongoDB service or daemon is running. The command for each output can be found below, followed by an example of what the output looks like. Just replace [Version] with Deadline’s major version:

  • Windows:

    sc query Deadline[VERSION]DatabaseService
    
        SERVICE_NAME: Deadline8DatabaseService
        TYPE        : 10  WIN32_OWN_PROCESS
        STATE       : 4   RUNNING
        ...
    
  • Mac OS X:

    ps aux | grep mongo
    
        root ... /Applications/Thinkbox/DeadlineDatabase8/mongo/application/bin/mongod --config /Applications/Thinkbox/DeadlineDatabase8/mongo/data/config.conf
    
  • Linux:

    ps aux | grep mongo
    
        root ... /opt/Thinkbox/DeadlineDatabase8/mongo/application/bin/mongod --config /opt/Thinkbox/DeadlineDatabase8/mongo/data/config.conf
    

Additional Information

If you’re looking for more information, here are some helpful links for manually installing the MongoDB database:

MongoDB also has a management system called MMS. It’s a cloud service that makes it easy to provision, monitor, backup, and scale your MongoDB database. Here are some helpful links for setting up and using MMS:

The Automation Agent mentioned above makes it possible to setup your MongoDB database from a web interface, and easily configure which MongoDB servers are replica sets or shards. It also allows you to easily upgrade the version of your MongoDB database. Here are some additional links for how you can use the Automation Agent:

Mongo and MongoDB are registered trademarks of MongoDB, Inc.