How can the Mongodb database service on the server be always enabled by default?
漂亮男人
漂亮男人 2017-05-02 09:23:54
0
2
743

After connecting to the server remotely, start the mongodb service on the server. How to keep the service running after disconnecting the remote connection

漂亮男人
漂亮男人

reply all(2)
大家讲道理

Use mongod -f to add the configuration file, set fork=true in it and run it in the background.
My mongo configuration file is in /data/mongo/27017.conf

port=27017 #端口号                                                                                                                                                                                       
  fork=true #以守护进程的方式运行,创建服务器进程
  master=true #单主从配置时设为主服务器
  #salve=true ##单主从配置时设为从服务器
  logpath=/data/mongo/27017/mongo.log #日志输出文件路径
  logappend=true #日志输出方式
  dbpath=/data/mongo/27017 #数据库路径
  #replSet=testrs #设置富本集的名字
  #shardsvr=true #设置是否分片
  auth=true#是否开启授权

Run the command mongod -f /data/mongo/27017.conf and it’s done

阿神

Thanks.

If I understand your question correctly, you use ssh to remotely log in to the server and start mongodb; then close the ssh connection and the service stops running.

It is recommended that when starting mongodb, let it run as a daemon process.

mongod adds --fork startup option.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template