Product DocsMenu

Installing MongoDB on a Server

Your Coveo instance must have access to a MongoDB database when you want to enable the URL shortener feature (see About the .NET Search Interface URL Shortener).

MongoDB supports basic authentication allowing you to secure the access to the database. Unless you install MongoDB in a secured environment, it is recommended to activate the MongoDB authentication and create and connect with a MongoDB user that has read and write permissions to the database.

Note: When you choose to use user-based security, you must include the username and password in the connection string (see Enabling the URL Shortener Database). As described in the following procedure, you enable the MongoDB authentication by including the --auth option when you register the MongoDB service.

To install MongoDB on a server

  1. Using an administrator account, connect to the server on which you want to install MongoDB as a Windows service.

  2. Download the latest production release of MongoDB for Windows (see the MongoDB document MongoDB Downloads).

    Note: On a 64-bit server, it is recommended to install the MongoDB 64-bit version to overcome the 2 GB database size limit of the 32-bit version (see the MongoDB document 32-bit limitations).

  3. Unzip the downloaded binary package to the location of your choice.

    Example: Unzip to C:\Program Files\mongodb-win32-x86_64-2.0.2 and rename to C:\Program Files\mongodb to have a version-independent folder name.

  4. Create the folder where MongoDB will store data:

    • Create the default folder [Same_Drive]\data\db.

      Example: C:\data\db\

      OR

    • Create a custom folder of your choice, in which case you must use the --dbpath option to specify the database folder when you register the MongoDB service.

      Example: Create the D:\MongoDB\folder.

  5. When you choose to enable the MongoDB authentication, create one or more MongoDB users that you will use to access one or more databases:

    Note: A MongoDB user has read and write permissions to the database to which it is added.

    1. Start the MongoDB interactive shell, by running the [MongoDB_Path]\bin\mongo.exe file.

      Example: Using Windows explorer, double-click the C:\Program Files\mongodb\bin\mongo.exe file.

    2. In the MongoDB interactive shell, if not already done, first switch to the admin database and create an administrator account.

      Example: To switch to the admin database and create an administrator user named admin with the password adminpassword, type the following commands:
      > use admin
      > db.addUser("admin", "adminpassword")        
    3. If not already authenticated, login as the administrator.

      Example:
      > db.auth("admin", "adminpassword")        
    4. Create the normal user for a new or existing database to be used by the Coveo Platform.

      Example: To create the URLShortener database and create a normal user named MyCoveoUser with the password MyPassword for this database, type the following commands:
      > use URLShortener
      > db.addUser("MyCoveoUser", "MyPassword")        

    Note: Refer to the MongoDB documentation when you need more information on the authentication (see the MongoDB document Configuring Authentication and Security).

  6. Register the MongoDB as a Windows service:

    1. Open a command line prompt (on the Windows taskbar, select Start, type cmd, and then press enter).

    2. Change directory to the MongoDB installation folder.

      Example: In the command line prompt, enter: cd \Program Files\MongoDB\bin

    3. Enter the following command:

      mongod --install --serviceName "MongoDB" [--dbpath [MongoDB_Folder]] [--logpath [MongoDB_Log_File]] [--auth]

      where:

      • you include the --dbpath option when you want to use a database folder other than the default one. Replace [MongoDB_Folder] by the desired path where MongoDB automatically creates the databases.

      • you include the --logpath option when you want to record MongoDB messages in a log file. Replace [MongoDB_Log_File] by the desired path and file name that MongoDB creates automatically. When omitted, MongoDB sends messages to the standard output (stdout).

      • you include the --auth option when you want to enable user authentication, restricting access only to users defined in MongoDB.

        Note: You must add at least one user from the interactive shell on the localhost before starting the server with authentication. You cannot add the first user from a connection that is not local with respect to mongod.

      Example: The following command registers MongoDB as a Windows service that will accept connections only for authenticated users:
      mongod --install --serviceName "MongoDB" --dbpath D:\MongoDB --logpath D:\MongoDB\MongoDB.log --auth
  7. Still in the command line prompt, start the service by typing the following command:

    net start MongoDB  

    Note: The MongoDB service will start automatically on future server startups.

What's Next?

Enable the desired optional database features (see Enabling the URL Shortener Database).

People who viewed this topic also viewed