Install MongoDB for Event Repository
A quick start guide for installing and configuring MongoDB for the Event Repository.
About this task
Install MongoDB Enterprise on every host server where MongoDB processes and tools are to run. For complete information about installing MongoDB, refer to your MongoDB product documentation. This section offers an abbreviated quick start guide for installing MongoDB using yum.
Procedure
-
Create a
/etc/yum.repos.d/mongodb-enterprise.repo file
with the following content on each of the MongoDB server machines:
Note: As of this writing, the repository-file URL of MongoDB Enterprise is as shown in the example that follows, where VERSION is the version number of the MongoDB release being installed. See the discussion about Event Repository system requirements for information about supported versions.[mongodb-enterprise]name=MongoDB Base Repositorybaseurl=https://repo.mongodb.com/yum/redhat/$releasever/mongodb-enterprise/VERSION/$basearch/gpgcheck=1enabled=1gpgkey=https://www.mongodb.org/static/pgp/server-VERSION.asc
-
Install MongoDB using yum:
sudo yum install -y mongodb-enterprise
-
To prevent MongoDB updates from being inadvertently installed on
your running MongoDB system, you can pin to the installed MongoDB by adding the
following exclude directive to the
/etc/yum.conf file on the servers:
exclude=mongodb-enterprise,mongodb-enterprise-server,mongodb-enterprise-shell,mongodb-enterprise-mongos,mongodb-enterprise-tools
Important: Whenever you reinstall or upgrade MongoDB, you must disable this line. -
(Sharded deployments only) Install the MongoDB mongodb-enterprise-mongos s (which has the
mongos
daemon) on every host server where MongoDB client applications are to run.mongos
can run on the same host servers where the client applications run (recommended). You can have onemongos
instance to each client application.To install only the
mongos
software and not the rest of MongoDB on a server, create a /etc/yum.repos.d/mongodb-enterprise.repo file but run the following yum command to install only the mongos server:sudo yum install -y mongodb-enterprise-mongosYou can add the same exclude directive to the /etc/yum.conf file on the servers.
-
(Recommended) Place the index files on a dedicated disk separate from the data
files. For this configuration, you set the option for storing indexes in
separate subdirectories, which tells MongoDB to store the index files in an
/index
subdirectory under the data directory, and you create a soft link named index in the data directory to point to the directory on the SSDs where the index files are to be stored. Create a target index directory for putting the index files on SSDs.If this is the setup, on all the MongoDB host servers (database servers), create a soft link named index in the data directory to point to the target index directory on the SSDs where you want the index files to be stored. The data directory is configured under the storage.dbPath entry in the configuration file. Change the ownership of any manually created target index directory to themongod
instance.sudo mkdir index_directory_fullpath sudo chown mongod:mongod index_directory_fullpath cd storage.dbPath ln –s index_directory_fullpath index
Where:
- storage.dbPath is the location of your data directory
- index is the newly created symlink in your data directory
- index-directory-fullpath is the full path of the directory on the SSDs where the index files are to be stored
For recommendations on where to place the MongoDB index files and data files, see the hardware section in the discussion about Event Repository system requirements. -
Create a key file for internal authentication. The key file enables each
mongod
instance to provide credentials as a member of the same cluster. For complete information about enabling internal authentication in MongoDB, refer to your MongoDB product documentation. Following are the general steps.openssl rand -base64 741 > mongodb-keyfile -
Copy this same key file to a location on each of the host servers
where MongoDB processes will run.
- For MongoDB non
sharded deployments, copy to each host server where members
(
mongod
) of the replica set will run. - For MongoDB sharded deployments, copy to each host server where shards (
mongod
), configuration servers (mongod
), and query routers (mongos
) will run.
scp mongodb-keyfile <host server running a MongoDB instance> - For MongoDB non
sharded deployments, copy to each host server where members
(
-
On each of the MongoDB host servers, read-protect the key file,
give it
mongod
ownership, and move it to the location you want. You will specify this location in the keyFile parameter of the mongod.conf file.chmod 400 mongodb-keyfilesudo chown mongod:mongod mongodb-keyfilesudo mkdir /srv/mongodbsudo mv mongodb-keyfile /srv/mongodb/The result should be similar to this:ls -l /srv/mongodb/mongodb-keyfile -r-------- 1 mongod mongod 1004 Dec 29 15:45 /srv/mongodb/mongodb-keyfile
What to do next
You are now ready to set configuration options in the MongoDB configuration file to be used by each of your MongoDB instances. On all the MongoDB host servers (database servers), you can replace
the default MongoDB configuration file /etc/mongod.conf with the one shown in the section entitled "MongoDB Configuration File Templates," entering appropriate
values for the bindIp
and cacheSizeGB
entries and ensuring that the values of all other entries are correct. For instructions, see the topic about
setting configuration options for the Event Repository.