Install RockMongo on CentOS 7
RockMongo is a web-based MongoDB Management tool that is similar to the MySQL Management tool, phpMyAdmin. This tutorial covers 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 fully-updated Vultr instance running CentOS 7 x64
- A sudo user.
1. 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
2. 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.
3. Install PHP 5
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
4. Install MongoDB
Follow our installation guide to install MongoDB on CentOS.
5. Configure 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
6. Install 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.