[root@localhost config]# mongod -f mongodb.conf
about to fork child process, waiting until server is ready for connections.
forked process: 3941
ERROR: child process failed, exited with 48
To see additional information in this output, start without the "--fork" option.

原因是已经MongoDB服务已经开过一个了

[root@localhost mongodb]# ps -ef | grep mongo
root       3429      1  1 01:06 ?        00:00:05 mongod --port=27017 --logpath=./log/mongodb.log --dbpath=./db --fork
root       4001   2124  0 01:15 pts/0    00:00:00 grep --color=auto mongo

解决办法也简单,将这个MongoDB服务关闭

[root@localhost mongodb]# mongo
MongoDB shell version v5.0.8
> use admin  
switched to db admin
> db.shutdownServer()        #关闭MongoDB服务
server should be down...
> exit        #退出
# 以下方式也可以
[root@localhost mongodb]# mongod --dbpath=./db --shutdown

关闭后就可以重启启动了

[root@localhost config]# cat mongodb.conf        #配置文件
systemLog:
  destination: file
  path: /usr/mongodb/log/mongodb.log
  logAppend: true
storage:
  dbPath: /usr/mongodb/db
  engine: wiredTiger
  journal:
    enabled: true
net:
  port: 27017
processManagement:
  fork: true


[root@localhost config]# mongod -f mongodb.conf  #这个是使用配置文件启动的
about to fork child process, waiting until server is ready for connections.
forked process: 4092
child process started successfully, parent exiting
[root@localhost config]#

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐