How to enable multiple admin users who can start and shutdown mongod

Hello,

I am using mongo on Linux, using a script to start and shutdown mongod server which internally uses following for start - mongodb/mongodb-linux-x86_64-rhel70-4.4.2/bin/mongod -f <config_file> --fork.
Any linux user which executes the script will be able to launch mongod.

My question is -

When a user A executes it first time, the mongod internal files that gets generated with the particular user A’s permission, when another user B tries to shut it down ( using mongodb/mongodb-linux-x86_64-rhel70-4.4.2/bin/mongod/bin/mongod -f <config_file> --shutdown ), it doesn’t allow it.

( or if same user A who started it, shut it down, then another user B won’t be able to start it again ).

How can we allow the multiple users to have control over admin operations ?

Welcome to the MongoDB Community @Jitendra_Singh_Chauhan !

I recommend installing using RPMs instead of manually unzipping and running from a path: Install MongoDB Community Edition on Red Hat or CentOS. The RPM install sets up a service definition so you can start/stop/restart the MongoDB service using a configuration file and consistent user/group process permissions.

On Linux you can use the /etc/sudoers file to control who has access to run commands as another user using the sudo utility. Usage and configuration of sudo isn’t specific to MongoDB. If you are looking for sudo configuration examples, there are quite a few on ServerFault such as Grant a user sudo powers to start/stop/etc a systemd service w/o sudo password.

Regards,
Stennie

1 Like

Hello @Stennie_X ,

We are not unzipping it manually, the mongo install path ( i.e. mongodb/mongodb-linux-x86_64-rhel70-4.4.2/ ) is something, provided by the customer.

Our use case is the following,

Customer installs the Mongo in their system, provides mongo install path to us when calling some commands which internally launches mongod using --fork, ( so dbpath and mongo install path resides in customer space ). [ it creates all files with 600 permissions ]

I havent’t tried service definition one yet but do you think there is any way we can allow multiple users to fork, shutdown mongod in current implementation ?