Centos7安装mongodb出现的问题:服务无法启动

原创 2016年12月18日 14:19:25

问题描述:

Centos7安装mongodb刚开始安装成功时执行sudo service mongod start 能启动,执行sudo service mongod status显示Active: active (running),但如果我重新启动系统,service又不能启动了。如果我卸载和再次安装,刚安装成功能启动服务,但在重新启动后,还是出现原来的状况,上代码:

[brody@localhost Desktop]$ sudo systemctl status  mongod.service
● mongod.service - High-performance, schema-free document-oriented database
   Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Sat 2016-12-17 21:35:08 CST; 3s ago
     Docs: https://docs.mongodb.org/manual
  Process: 1570 ExecStart=/usr/bin/mongod $OPTIONS run (code=exited, status=1/FAILURE) 
Main PID: 1570 (code=exited, status=1/FAILURE)

Dec 17 21:35:08 localhost.localdomain systemd[1]: Started High-performance, s...
Dec 17 21:35:08 localhost.localdomain systemd[1]: Starting High-performance, ...
Dec 17 21:35:08 localhost.localdomain mongod[1570]: about to fork child proce...
Dec 17 21:35:08 localhost.localdomain mongod[1570]: forked process: 1591
Dec 17 21:35:08 localhost.localdomain systemd[1]: mongod.service: main proces...
Dec 17 21:35:08 localhost.localdomain systemd[1]: Unit mongod.service entered...
Dec 17 21:35:08 localhost.localdomain systemd[1]: mongod.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

解决办法:

1.编辑mongod.conf
sudo vim /etc/mongod.conf

把fork修改为 false , pidFilePath修改为dbPath的路径,我这里在storage显示为dbPath: /var/lib/mongo,即设置为:
fork: false # fork and run in background
pidFilePath: /var/lib/mongo/mongod.pid # location of
如下所是:

# Where and how to store data.
storage:
  dbPath: /var/lib/mongo
  journal:
    enabled: true
#  engine:
#  mmapv1:
#  wiredTiger:
# how the process runs
processManagement:
  fork: false  # fork and run in background
  pidFilePath: /var/lib/mongo/mongod.pid  # location of pidfile
2.设置firewall
sudo firewall-cmd --zone=public --permanent --add-port=27017/tcp; firewall-cmd --reload
3.重启查看验证
sudo tail -f /var/log/mongodb/mongod.log  & systemctl restart mongod; systemctl status mongod
4.重启电脑

参考文献:
[1]Stack Overflow http://stackoverflow.com/questions/40829306/mongodb-cant-start-centos-7
[2]官方文档https://docs.mongodb.com/manual/reference/configuration-options/#storage.wiredTiger

CentOS 6.5下通过yum安装MongoDB记录

最近想尝试一下英特尔的基于WebRTC协同通信开发套件,其中的CS_WebRTC_Conference_Server_MCU依赖MongoDB。MongoDB是什么?MongoDB 是一个基于分布式文...
  • testcs_dn
  • testcs_dn
  • 2016-02-19 16:17:46
  • 6733

Linux -- Mongodb

[root@Arch ~]# systemctl -l status mongodb.service ● mongodb.service - High-performance, schema-fre...
  • u011130746
  • u011130746
  • 2014-11-26 18:51:25
  • 2857

centos 7 如何安装启动使用mongodb

参考mongodb官网的安装步骤: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/添加安装包的配置文件创建一...
  • liujingqiu
  • liujingqiu
  • 2017-07-15 11:20:59
  • 1021

linux下mongodb的安装及启动

1>设置mongoDB目录 cd /home/apps      附:centOS下创建目录命令  mkdir /home/apps 2>下载mongodb curl -O http...
  • huwei2003
  • huwei2003
  • 2014-10-27 16:25:18
  • 21862

MongoDB server端的启动和添加到服务。

MongoDB server端的启动和添加到服务。
  • ribavnu
  • ribavnu
  • 2016-06-10 15:45:56
  • 1736

学习MongoDB 三: MongoDB无法启动的解决方法

我们之前介绍了MongoDB入门(安装与配置),我们今天在打开MongDB时,我们先运行cmd.exe进入dos命令界面,然后进入cd D:\mongodb\bin目录下,启动服务或者mongo命令...
  • congcong68
  • congcong68
  • 2015-07-05 19:09:48
  • 10709

【Linux】启动mongo db后台服务

文章目录1. 开启mongo db后台服务2. 关闭mongo db服务3. 走过的弯路将mongodb部署在服务器机子上时mongodb的实例应为后台服务进行的方式运行,而非前台进程,否则远程会话一...
  • sodino
  • sodino
  • 2016-09-01 18:19:28
  • 6567

Mongo:Failed to start High-performance, schema-free document-oriented database

Mongo报错Failed to start High-performance, schema-free document-oriented database。由于mongo服务器ip地址发生变化,导...
  • zzm628
  • zzm628
  • 2018-03-26 22:19:13
  • 59

mongodb 在centos7里用systemctl起不来

两个问题造成 1、/var/run/mongodb/mongod.pid 文件已存在 2、logpath和dbpath下的文件的权限问题:都得用 sudo chown mongod:mongod...
  • zhao4471437
  • zhao4471437
  • 2016-11-14 17:58:17
  • 2367

centos7开机启动mongodb shard cluster

centos7开机启动mongodb shard cluster 分享光荣,盗链可耻。转载务必注明出处,鄙视盗链鼠辈。 shard配置 shard node1配置 shardsvr=true...
  • secretx
  • secretx
  • 2015-06-26 10:10:53
  • 3286
收藏助手
不良信息举报
您举报文章:Centos7安装mongodb出现的问题:服务无法启动
举报原因:
原因补充:

(最多只允许输入30个字)