如何让 MongoDB 服务器在 Linux Startup (CentOS) 上启动

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9754809/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 12:32:30  来源:igfitidea点击:

How to make MongoDB Server start on Linux Startup (CentOS)

mongodbcentos

提问by Shehabic

I'm using Linux CentOS 5.4, I installed MongoDB now it's availabled as a Daemon and Service

我使用的是 Linux CentOS 5.4,我安装了 MongoDB 现在它可以作为守护进程和服务使用

When I execute service mongod start is says : [OK] --> in green as if the service started but when I try to connect to it I find it not working.

当我执行 service mongod start 时说:[OK] --> 绿色,好像服务已启动,但是当我尝试连接到它时,我发现它不起作用。

but when I try to run "mongod" from the shell normally it starts but if I closed the shell connections it stops.

但是当我尝试从 shell 正常运行“mongod”时,它会启动,但是如果我关闭了 shell 连接,它就会停止。

how do I add it to the start up of the OS ? or how do I run it in the background ?

如何将其添加到操作系统的启动中?或者我如何在后台运行它?

回答by

add /usr/bin/mongodto /etc/rc.localthis will make it start with the startup scripts

添加/usr/bin/mongod/etc/rc.local这将使其从启动脚本开始

回答by nickzam

I think you need to create basic init scripts to start Mongodb as daemon and create mongodb user. Detailed information can be found here: Mongo DB installation

我认为您需要创建基本的初始化脚本以将 Mongodb 作为守护程序启动并创建 mongodb 用户。详细信息可以在这里找到:Mongo DB 安装