After connecting to the server remotely, start the mongodb service on the server. How to keep the service running after disconnecting the remote connection
大家讲道理2017-05-02 09:25:54
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
阿神2017-05-02 09:25:54
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.