RHEL环境变量路径到Mongo Shell

时间:2017-04-01 19:18:38

标签: bash mongodb shell rhel mongodb-mms

我在我们的一个环境中安装了mongodb&这是使用MongoDb Operations Manager完成的。虽然我正确设置了PATH变量,但我无法将mongo shell与我的用户帐户连接,但能够以sudo身份连接。如果我在这里遗失任何东西,有人可以帮助我。

详细说明:

[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>

哪个Mongo输出:

[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

观察:

我刚注意到bin位置设置如下......

[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

2 个答案:

答案 0 :(得分:1)

试试这个

sudo chmod -R 777 /var/lib/mongodb-mms-automation/mongodb-linux-x86_64-3.2.10-ent/bin/

答案 1 :(得分:0)

将此添加到路径/var/lib/mongodb-mms-automation/mongodb-linux-x86_64-3.2.10-ent/bin