非root用户安装 mongodb

需求

服务器非root用户,无sudo权限,安装mongodb并正常使用。

简而言之,解决方案是从tar安装binary的mognodb,并修改配置文件。

参考资料

https://groups.google.com/forum/#!topic/mongodb-user/DUpcIkoAv88

If you want to install MongoDB without root/sudo access required in any steps, you can use the generic Linux binaries instead of the packaged install:
http://docs.mongodb.org/manual/tutorial/install-mongodb-on-linux/

You’ll have to create your own service definition and config file (or pass parameters on the command line when starting mongod). Assuming you have correct permissions on the provided dbpath, you can run the MongoDB binaries from any directory (as any user).

For an example config see:
https://github.com/mongodb/mongo/blob/master/rpm/mongod.conf

Note that packaged installs run MongoDB as the mongod user or another non-root account. The packages only require root/sudo access for installing and managing the service (start/stop/restart).

Regards,
Stephen

配置

将命令添加到rc文件

bashrc
export PATH=~/mongodb/mongodb-linux-x86_64-3.4.2/bin:$PATH

配置数据库存储位置

~/data/db
数据库启动 mongod –dbpath ~/data/db

ssh 后台运行

待添加