SOLVED mongoDB in cPanel

Tarak Nath

Well-Known Member
Mar 12, 2018
91
14
8
India
cPanel Access Level
Root Administrator
Hello,

We know that mongoDB is not supported in cPanel. But we need to develop a Laravel project with mongoDB and that's why we have installed mongoDB 3.6. Everything is working fine as expected through root user. Below are the mongoDB info:
Code:
==========
[email protected] [/]# mongod -version
db version v3.6.12
git version: c2b9acad0248ca06b14ef1640734b5d0595b55f1
OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
allocator: tcmalloc
modules: none
build environment:
    distmod: rhel70
    distarch: x86_64
    target_arch: x86_64
----------------------------
[email protected] [/]# systemctl status mongod
● mongod.service - High-performance, schema-free document-oriented database
   Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2019-04-18 07:21:47 EDT; 2h 5min ago
     Docs: The MongoDB 4.0 Manual — MongoDB Manual
 Main PID: 21425 (mongod)
   CGroup: /system.slice/mongod.service
           └─21425 /usr/bin/mongod -f /etc/mongod.conf

Apr 18 07:21:45 server1.mydomain.com systemd[1]: Starting High-performance, schema-free document-oriented database...
Apr 18 07:21:45 server1.mydomain.com mongod[21423]: about to fork child process, waiting until server is ready for connections.
Apr 18 07:21:45 server1.mydomain.com mongod[21423]: forked process: 21425
Apr 18 07:21:47 server1.mydomain.com mongod[21423]: child process started successfully, parent exiting
Apr 18 07:21:47 server1.mydomain.com systemd[1]: Started High-performance, schema-free document-oriented database.
----------------------------
[email protected] [/]# mongo
MongoDB shell version v3.6.12
connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("04a2eb10-8ee6-4ca3-bc7c-55bc00510047") }
MongoDB server version: 3.6.12
Server has startup warnings:
2019-04-18T07:21:45.974-0400 I STORAGE  [initandlisten]
2019-04-18T07:21:45.974-0400 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2019-04-18T07:21:45.974-0400 I STORAGE  [initandlisten] **          See Production Notes — MongoDB Manual
2019-04-18T07:21:47.098-0400 I CONTROL  [initandlisten]
2019-04-18T07:21:47.098-0400 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2019-04-18T07:21:47.098-0400 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2019-04-18T07:21:47.098-0400 I CONTROL  [initandlisten]
2019-04-18T07:21:47.098-0400 I CONTROL  [initandlisten]
2019-04-18T07:21:47.098-0400 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2019-04-18T07:21:47.098-0400 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2019-04-18T07:21:47.098-0400 I CONTROL  [initandlisten]
2019-04-18T07:21:47.098-0400 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2019-04-18T07:21:47.098-0400 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2019-04-18T07:21:47.098-0400 I CONTROL  [initandlisten]
>

==========
Only one things we are facing that we are unable to run 'mongo' command via cPanel user terminal, we are getting "-bash: mongo: command not found". Below are the few information of our server, kindly go through and help us.

Installed cPanel Version Details
[email protected] [/]# /usr/local/cpanel/cpanel -V
78.0 (build 20)
==================
Current cPanel Environment:

[email protected] [/]# cat /var/cpanel/envtype
standard
==================
OS Version:

[email protected] [/]# cat /etc/redhat-release
CloudLinux release 7.6 (Vladimir Lyakhov)

Any suggestion would be appreciated.

Thanks,
Tarak Nath
 
Last edited by a moderator:

GOT

Get Proactive!
PartnerNOC
Apr 8, 2003
1,755
311
363
Chesapeake, VA
cPanel Access Level
DataCenter Provider
Since you are running CloudLinux does that mean you have also enabled cagefs? I'm not sure what all would be involved but you can either take this user out of cagefs or you can add the mongo command to the cage skeleton.
 

GOT

Get Proactive!
PartnerNOC
Apr 8, 2003
1,755
311
363
Chesapeake, VA
cPanel Access Level
DataCenter Provider
If you don't have cagefs enabled then that would not be interfering.

It's more likely in this case that mongo is in a path that the user does not have in their default path.

Make sure the users shell is set to bash and not jailshell and then use the full path to the mongo binary when executing it.

The user may also not have per.issikns on the command either
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,909
2,222
463
Hello @Tarak Nath,

First, execute the following command as root to find the full path to Mongo:

Code:
which mongo
Then, access SSH as the user and enter the full path (e.g. /usr/local/bin/mongo) when executing a mongo command.

Let me know if this helps.

Thank you.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,909
2,222
463
[email protected]# /usr/bin/mongo bash: /usr/bin/mongo: No such file or directory
Hello @Tarak Nath,

You mentioned using CloudLinux with CageDS disabled. Are you positive that CageFS is disabled? You can review the CageFS document below to verify if it's installed or uninstalled:

Command-line Tools

If it's installed, you'll need to perform the steps noted on the following document (replacing "java" with "mongo"):

How to add java to CageFS

Let me know if this helps.

Thank you.
 

Tarak Nath

Well-Known Member
Mar 12, 2018
91
14
8
India
cPanel Access Level
Root Administrator
Hello,

I meant to say that said user is in the CageFS not out of CageFS.

For testing purposes I have removed the said user from CageFS and noticed that said user able to run 'mongo' command.

Is it best practices to remove the user from CageFS for security reasons? Or add the 'mongo' command to CageFS?
What you suggest us?

Thanks,
Tarak Nath
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,909
2,222
463
Is it best practices to remove the user from CageFS for security reasons? Or add the 'mongo' command to CageFS?
Hello @Tarak Nath,

Making the "mongo" command available to CageFS is generally the better approach compared to disabling CageFS completely for a user.

Thank you.
 

Tarak Nath

Well-Known Member
Mar 12, 2018
91
14
8
India
cPanel Access Level
Root Administrator
Hi @cPanelMichael ,

Thank you for your suggestion.

As per the document How to add java to CageFS we made the "mongo" command available to CageFS and its perfectly working from cPanel user's terminal which we wanted.

Again thank you very much for your suggestion & support. Really its very appreciated.

Kindly mark this thread as 'SOLVED'.

Regards,
Tarak Nath