MongoDB Ops Manager on CentOS

Posted on by Bertrand Thomas
How-to Database Automation Linux

Let's see how to install MongoDB Ops Manager on CentOS.

Installation

Install a Simple Test Ops Manager Installation

Simple test deployment on CentOS

This is an interesting first step and can be used for non-production environments (dev, staging). You can validate many aspects about the procedure, such as the ports to be opened and OS options.

All Ops Manager components will run on the same server: db, backup, application.

MongoDB needs to be first installed and configured to host Ops Manager data & backup.

Pre-requisites (hosts, ntpupdate, mongod, firewall)

:warning: Make sure to correctly update either your DNS or the /etc/hosts file of every server, a small typo can lead to complicated investigation (true story).

# make sure ntp & ntpupdate are installed (this is important for the communication between servers)
sudo yum install ntpupdate
sudo ntpdate 0.centos.pool.ntp.org
# install MongoDB server & shell
echo "[mongodb-org-3.6]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/amazon/2013.03/mongodb-org/3.6/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.6.asc" | sudo tee /etc/yum.repos.d/mongodb.repo
sudo yum install -y mongodb-org mongodb-org-shell
# for info: user mongod and group mongod have been created (you can add your user in mongod group)
cat /etc/passwd
cat /etc/group
# service mongod is launched by default, stop it and prevent it from being started on server startup
service mongod status
sudo service mongod stop
sudo chkconfig --level 35 mongod off
# create the directories for mongod: application database, backup, logs
sudo mkdir -p /data/my/folder
sudo chown -R mongod:mongod /data/my/folder
sudo chmod 770 -R /data/my/folder
# open Ops Manager ports
sudo firewall-cmd --permanent --zone=public --add-port=8080/tcp
sudo firewall-cmd --permanent --zone=public --add-port=8443/tcp
sudo firewall-cmd --permanent --zone=public --add-port=27000-28000/tcp
sudo firewall-cmd --permanent --zone=public --add-port=25/tcp
sudo firewall-cmd --reload

Configure & launch MongoDB databases for Ops Manager (app & backup)

# path will depend on your directory strategy, cache size from your server capacity
sudo -u mongod mongod --port 27017 --dbpath /data/mongodb/opsmanager/appdb --logpath /data/mongodb/opsmanager/logs/appdb.log --wiredTigerCacheSizeGB 1 --fork
sudo -u mongod mongod --port 27018 --dbpath /data/mongodb/opsmanager/backup --logpath /data/mongodb/opsmanager/logs/backup.log  --fork
# you can check they are up and running
ps -ef | grep mongod

Download and install Ops Manager (previously known as MongoDB Monitoring Service, aka MMS)

# retrieve and install the selected version
curl -OL https://downloads.mongodb.com/on-prem-mms/rpm/mongodb-mms-3.6.3.606-1.x86_64.rpm
sudo rpm -ivh mongodb-mms-3.6.3.606-1.x86_64.rpm
# Preparing...                          ################################# [100%]
# Updating / installing...
#    1:mongodb-mms-3.6.3.606-1          ################################# [100%]
# the installation will create the following
# base directory for the Ops Manager software has been created
ll /opt/mongodb/mms
# mongodb-mms user and group have been created
cat /etc/passwd
cat /etc/group
# edit & review properties file (contains the connection string to app db)
sudo vi /opt/mongodb/mms/conf/conf-mms.properties
# start Ops Manager!
sudo service mongodb-mms start
# Generating new Ops Manager private key...
# Starting pre-flight checks
# Successfully finished pre-flight checks
# Migrate Ops Manager data
#    Running migrations...[  OK  ]
# Start Ops Manager server
#    Instance 0 starting...............[  OK  ]
# Starting pre-flight checks
# Successfully finished pre-flight checks
# Start Backup Daemon...[  OK  ]

Automation agent

Ops Manager can automate all your MongoDB instances and servers thanks to the Automation Agent that must be installed on all servers.

CentOS (tutorial from mongodb.com)

This procedure has been validated against CentOS Linux release 7.4.1708 (Core)

# make sure ntp & ntpupdate are installed
sudo yum install ntpupdate
sudo ntpdate 0.centos.pool.ntp.org
# ports should not be used and firewall allows traffic on these ports between the servers
sudo firewall-cmd --permanent --zone=public --add-port=8080/tcp
sudo firewall-cmd --permanent --zone=public --add-port=8443/tcp
sudo firewall-cmd --permanent --zone=public --add-port=27000-28000/tcp
sudo firewall-cmd --reload
# make sure all URLS are known
sudo vi /etc/hosts
# for example on Ops Manager URL
curl -ivs http://myopsmanagerurl:8080
# download the package file from Ops Manager and install it
curl -OL http://myopsmanagerurl:8080/download/agent/automation/mongodb-mms-automation-agent-manager-latest.x86_64.rpm
sudo rpm -U mongodb-mms-automation-agent-manager-latest.x86_64.rpm
# follow the comments to fill mmsGroupId, mmsApiKey, mmsBaseUrl
sudo vi /etc/mongodb-mms/automation-agent.config
# create data directory
sudo mkdir /data
sudo chown mongod:mongod /data
# start the automation agent
sudo service mongodb-mms-automation-agent start
# check its status
sudo service mongodb-mms-automation-agent status
# investigate issues
ll /var/log/mongodb-mms-automation
sudo more /var/log/mongodb-mms-automation/automation-agent-fatal.log

Ubuntu (tutorial from mongodb.com)

Updates made from docs.cloudmanager.mongodb.com.

This procedure has been validated against Ubuntu 16.04.1 LTS

# make sure ntp & ntpupdate are installed
sudo apt install
sudo ntpdate 0.centos.pool.ntp.org
# make sure ops manager url is known
sudo vi /etc/hosts
curl -ivs http://myopsmanagerurl:8080
# replace the URL
curl -OL http://myopsmanagerurl:8080/download/agent/automation/mongodb-mms-automation-agent-manager_latest_amd64.ubuntu1604.deb
sudo dpkg -i mongodb-mms-automation-agent-manager_latest_amd64.ubuntu1604.deb
# Selecting previously unselected package mongodb-mms-automation-agent-manager.
# (Reading database ... 254031 files and directories currently installed.)
# Preparing to unpack mongodb-mms-automation-agent-manager_latest_amd64.ubuntu1604.deb ...
# Unpacking mongodb-mms-automation-agent-manager (4.5.11.2453-1) ...
# Setting up mongodb-mms-automation-agent-manager (4.5.11.2453-1) ...
# follow the comments to fill mmsGroupId, mmsApiKey, mmsBaseUrl
sudo vi /etc/mongodb-mms/automation-agent.config
# create data directory
sudo mkdir /data
sudo chown mongodb:mongodb /data
# start the automation agent
sudo systemctl start mongodb-mms-automation-agent.service
# check its status
sudo systemctl status mongodb-mms-automation-agent.service
# investigate issues
ll /var/log/mongodb-mms-automation

Configuration

Monitoring

Backup

mkdir /data/mongodb/backupdaemon
sudo chown mongodb-mms:mongodb-mms /data/mongodb/backupdaemon
sudo sudo chmod 774 -R /data/mongodb/backupdaemon

Email sending

If you have an error while sending the test message, you can test directly from Ops Manager server.

sudo yum install telnet
telnet smtp.mycompany.lan 25

Appendix

Follow what's going on

You can tail the automataion log file.

tail -f /var/log/mongodb-mms-automation/automation-agent.log

You can also look at the processes running on a MongoDB server.

ps -ef | grep mongo
# mongod    23947      1  0 14:15 ?        00:00:03 /var/lib/mongodb-mms-automation/mongodb-linux-x86_64-3.6.2/bin/mongod -f /data/rsDev2_12/automation-mongod.conf
sudo more /data/rsDev2_12/automation-mongod.conf
# THIS FILE IS MAINTAINED BY http://myopsmanager:8080 . DO NOT MODIFY AS IT WILL BE OVERWRITTEN.
# To make changes to your MongoDB deployment, please visit http://myopsmanager:8080 . Your Group ID is xxxxxxxxxxxxxxxxxxxxx .
net:
  bindIp: 0.0.0.0
  port: 27000
processManagement:
  fork: "true"
replication:
  replSetName: rsDev2
storage:
  dbPath: /data/rsDev2_12
systemLog:
  destination: file
  path: /data/rsDev2_12/mongodb.log
sudo tail -f /data/rsDev2_12/mongodb.log

Cleanup a MongoDB server

In case of issues, you may want to clean a server where a MongoDB automation agent was installed, or simply a MongoDB server.

Warnings

If you followed this procedure, you will probably get this warnings.