0

I have installed mongodb in one of our environments & this has been done using MongoDb Operations Manager. Though i have my PATH variable set correctly i'm unable to connect mongo shell with my user account but able to connect as a sudo. could someone help me if i'm missing anything here.

Details:

[user01@west.company.com@rhel01 /]$ echo $PATH
> /var/lib/mongodb-mms-automation/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/nfs/home/user01/.local/bin:/nfs/home/user01/bin 
[user01@west.company.com@rhel01 /]$ mongo
> -bash: mongo: command not found

[user01@west.company.com@rhel01 /]$ sudo -i 
[sudo] password for user01@west.company.com: 
[root@rhel01 ~]# echo $PATH
> /var/lib/mongodb-mms-automation/bin:/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin 
[root@rhel01 ~]# mongo 
> MongoDB shell
> version: 3.2.10 connecting to: test 
> MongoDB Enterprise MYMONGOREPLSET01:PRIMARY>

Which Mongo Output:

[user01@west.company.com@rhel01 /]$ which mongo
/usr/bin/which: no mongo in (/var/lib/mongodb-mms-automation/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/nfs/home/user01/.local/bin:/nfs/home/user01/bin)

[root@rhel01 ~]# which mongo
/var/lib/mongodb-mms-automation/bin/mongo

Observation:

i just noticed the bin location is set like this ...

[root@rhel01 mongodb-mms-automation]# pwd
/var/lib/mongodb-mms-automation
[root@rhel01 mongodb-mms-automation]# ls -la
total 32
drwxr-xr-x   3 mongod mongod  4096 Mar 30 13:58 .
drwxr-xr-x. 57 root   root    4096 Apr  1 03:23 ..
lrwxrwxrwx   1 mongod mongod    67 Nov  4 13:45 bin -> /var/lib/mongodb-mms-automation/mongodb-linux-x86_64-3.2.10-ent/bin
-rw-------   1 mongod mongod  1024 Mar 27 15:07 keyfile
-rw-------   1 mongod mongod 10686 Mar 30 13:58 mms-cluster-config-backup.json
drwxr-x---   4 mongod mongod  4096 Nov  4 13:45 mongodb-linux-x86_64-3.2.10-ent
Siva Dasari
  • 1,059
  • 2
  • 19
  • 40

2 Answers2

1

Try this

sudo chmod -R 777 /var/lib/mongodb-mms-automation/mongodb-linux-x86_64-3.2.10-ent/bin/
shahin
  • 3,515
  • 1
  • 17
  • 17
  • Being your current user (not as root) , go to that location and execute : " ./mongo" then comment your output – shahin Apr 02 '17 at 17:52
  • sure, I will check & post the result. – Siva Dasari Apr 03 '17 at 15:31
  • while checking the permissions, noticed that the root folder doesn't have execute permissions for the user. so, did the following & it worked. Thanks Shahin :) sudo chmod -R 755 /var/lib/mongodb-mms-automation/mongodb-linux-x86_64-3.2.10-ent – Siva Dasari Apr 03 '17 at 18:24
0

add this to path /var/lib/mongodb-mms-automation/mongodb-linux-x86_64-3.2.10-ent/bin

Edik Mkoyan
  • 309
  • 2
  • 17
  • I added it but still it didn't work ... here is my PATH after appending. /var/lib/mongodb-mms-automation/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/nfs/home/user01/.local/bin:/nfs/home/user01/bin:/var/lib/mongodb-mms-automation/mongodb-linux-x86_64-3.2.10-ent/bin – Siva Dasari Apr 01 '17 at 20:08