Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

SOLVED mongoDB in cPanel

Discussion in 'Database Discussion' started by Tarak Nath, Apr 18, 2019.

Tags:
  1. Tarak Nath

    Tarak Nath Well-Known Member

    Joined:
    Mar 12, 2018
    Messages:
    66
    Likes Received:
    10
    Trophy Points:
    8
    Location:
    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:
    ==========
    root@server1 [/]# 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
    ----------------------------
    root@server1 [/]# 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.
    ----------------------------
    root@server1 [/]# 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
    root@server1 [/]# /usr/local/cpanel/cpanel -V
    78.0 (build 20)
    ==================
    Current cPanel Environment:

    root@server1 [/]# cat /var/cpanel/envtype
    standard
    ==================
    OS Version:

    root@server1 [/]# cat /etc/redhat-release
    CloudLinux release 7.6 (Vladimir Lyakhov)

    Any suggestion would be appreciated.

    Thanks,
    Tarak Nath
     
    #1 Tarak Nath, Apr 18, 2019
    Last edited by a moderator: Apr 18, 2019
  2. GOT

    GOT Get Proactive! PartnerNOC

    Joined:
    Apr 8, 2003
    Messages:
    1,355
    Likes Received:
    147
    Trophy Points:
    193
    Location:
    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.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. Tarak Nath

    Tarak Nath Well-Known Member

    Joined:
    Mar 12, 2018
    Messages:
    66
    Likes Received:
    10
    Trophy Points:
    8
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Thank you @GOT for your response.

    No, I have not enabled cagefs yet. Should I enable so that we can run "mongo" command from cPanel terminal?

    Thanks,
    Tarak Nath
     
  4. GOT

    GOT Get Proactive! PartnerNOC

    Joined:
    Apr 8, 2003
    Messages:
    1,355
    Likes Received:
    147
    Trophy Points:
    193
    Location:
    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
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    47,005
    Likes Received:
    2,123
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    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.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. Tarak Nath

    Tarak Nath Well-Known Member

    Joined:
    Mar 12, 2018
    Messages:
    66
    Likes Received:
    10
    Trophy Points:
    8
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Hello @cPanelMichael ,

    Below is the output as root:

    Code:
    
    root@server1 [~]# which mongo
    /usr/bin/mongo
    
    
    And below is out put as cPanel user:

    Code:
    user@server1# /usr/bin/mongo
    bash: /usr/bin/mongo: No such file or directory
    
    We are facing same issue.

    Thanks,
    Tarak Nath
     
  7. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    47,005
    Likes Received:
    2,123
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    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.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. Tarak Nath

    Tarak Nath Well-Known Member

    Joined:
    Mar 12, 2018
    Messages:
    66
    Likes Received:
    10
    Trophy Points:
    8
    Location:
    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
     
  9. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    47,005
    Likes Received:
    2,123
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    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.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  10. Tarak Nath

    Tarak Nath Well-Known Member

    Joined:
    Mar 12, 2018
    Messages:
    66
    Likes Received:
    10
    Trophy Points:
    8
    Location:
    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
     
  11. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    47,005
    Likes Received:
    2,123
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello @Tarak Nath,

    I'm happy to see that helped. I've marked this thread as solved.

    Thanks!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  12. ashwinilute

    ashwinilute Registered

    Joined:
    May 8, 2019
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Nagpur
    cPanel Access Level:
    DataCenter Provider
    We can go with the @Tarak Nath code which is very useful.
     
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice