Install RockMongo on CentOS 7

Published on: Sat, Jan 30, 2016 at 8:13 am EST
CentOS Databases Linux Guides MongoDB Server Apps Web Servers

RockMongo is a web-based MongoDB Management tool that is similar to the MySQL Management tool: phpMyAdmin.

This tutorial will cover the process of installing and using RockMongo on CentOS 7 x64.

Prerequisites

In order to get hands-on experiences from this tutorial, you need to:

  • A Vultr instance running CentOS 7 x64
  • A sudo user.

Step 1: Update and reboot your server

sudo yum update
sudo shutdown -r now

After the reboot, use the same sudo user to log in again.

Step 2: Install Apache

Since RockMongo is web-based, you need to have a running web server. For the purpose of this tutorial, we will be using Apache:

sudo yum install httpd
sudo systemctl start httpd.service
sudo systemctl enable httpd.service

Step 3: Setup the firewall

In order to access RockMongo from your browser, you need to allow the http traffic to get through the firewall.

sudo firewall-cmd --zone=public --permanent --add-service=http
sudo firewall-cmd --reload

Then you can visit http://[YourServerIP] from your browser to verify your setup.

Step 4: Install PHP 5 and all the necessary extensions

RockMongo is a PHP 5-based software. You need to install PHP 5 and some extensions in order for RockMongo to function properly:

sudo yum install php php-devel php-pear php-pecl-mongo
sudo yum install gcc openssl.x86_64 openssl-devel.x86_64
sudo pecl install mongodb
echo 'extension=mongodb.so' | sudo tee -a /etc/php.ini

Step 5: Install the latest stable version of MongoDB

Here, I will use Yum to install MongoDB 3.2.1 which as of writing is the latest stable version of MongoDB.

First, create a Yum repo for MongoDB:

cd /etc/yum.repos.d
sudo vi mongodb-org-3.2.repo

Populate this file with:

[mongodb-org-3.2]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/x86_64/
gpgcheck=0
enabled=1

Save and quit:

:wq!

Then install and setup MongoDB using the following commands:

sudo yum install -y mongodb-org
sudo systemctl start mongod.service
sudo systemctl enable mongod.service

Step 6: Configure the system to prevent warning messages when using MongoDB

Some configuration tweaks are required before you can start using MongoDB:

a) Disable the transparent huge pages

For this purpose, you need to create a startup script:

sudo vi /etc/init.d/disable-transparent-hugepages

Copy the following code section into it:

#!/bin/sh
### BEGIN INIT INFO
# Provides:          disable-transparent-hugepages
# Required-Start:    $local_fs
# Required-Stop:
# X-Start-Before:    mongod mongodb-mms-automation-agent
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Disable Linux transparent huge pages
# Description:       Disable Linux transparent huge pages, to improve
#                    database performance.
### END INIT INFO

case $1 in
  start)
    if [ -d /sys/kernel/mm/transparent_hugepage ]; then
      thp_path=/sys/kernel/mm/transparent_hugepage
    elif [ -d /sys/kernel/mm/redhat_transparent_hugepage ]; then
      thp_path=/sys/kernel/mm/redhat_transparent_hugepage
    else
      return 0
    fi

    echo 'never' > $/enabled
    echo 'never' > $/defrag

    unset thp_path
    ;;
esac

Save and quit:

:wq!

Make sure the script is executable and added to the system startup:

sudo chmod 755 /etc/init.d/disable-transparent-hugepages
sudo chkconfig --add disable-transparent-hugepages

Additionally, you need to adjust the tuned configuration:

sudo mkdir /etc/tuned/no-thp
sudo vi /etc/tuned/no-thp/tuned.conf

Copy the following content into it:

[main]
include=virtual-guest

[vm]
transparent_hugepages=never

Save and quit:

:wq!

Execute tuned-adm:

sudo tuned-adm profile no-thp

b) Configure ulimit values

sudo vi /etc/security/limits.conf

Append the following 4 rows to the end of this file:

mongod soft nofile 64000
mongod hard nofile 64000
mongod soft nproc 32000
mongod hard nproc 32000

Save and quit:

:wq!

Reboot the system to put your changes into effect:

sudo shutdown -r now

Step 7: Install and Use RockMongo

Download the latest stable release of RockMongo from GitHub:

cd ~
wget https://github.com/iwind/rockmongo/archive/1.1.7.tar.gz
tar zxvf 1.1.7.tar.gz

For security purposes, you need to modify the RockMongo administrator's username and password:

vi rockmongo-1.1.7/config.php

Find the following row:

$MONGO["servers"][$i]["control_users"]["admin"] = "admin";//one of control users ["USERNAME"]=PASSWORD, works only if mongo_auth=false

In this row, modify the first admin string as your custom username, the second admin string as your custom password. Then save and quit:

:wq!

Finally, move the whole directory to your Web directory:

sudo mv ~/rockmongo-1.1.7 /var/www/html/

Now, you can visit http://[YourServerIP]/rockmongo-1.1.7 from your browser and log in RockMongo with the credentials you setup earlier.

This concludes our tutorial. Thank you for reading.

Want to contribute ?

You could earn up to $300 by adding new articles