小编典典

MongoDB服务未在Fedora中运行

linux

刚在Fedora 17 64位上安装了干净版本的mongodb,但是Mongo服务无法运行。

我在安装过程中遵循了这些说明

跑步

service mongod start

结果是

Starting mongod (via systemctl):  Job failed. See system journal and 'systemctl status' for details.  [FAILED]

所以我跑了

systemctl status mongod.service

这给了我

mongod.service - SYSV: Mongo is a scalable, document-oriented database.
  Loaded: loaded (/etc/rc.d/init.d/mongod)
  Active: failed (Result: exit-code) since Mon, 18 Jun 2012 13:15:56 +0200; 58s ago
 Process: 13584 ExecStart=/etc/rc.d/init.d/mongod start (code=exited, status=1/FAILURE)
  CGroup: name=systemd:/system/mongod.service

Mongo登录/var/log/mongo/mongod.log为空

谢谢


阅读 439

收藏
2020-06-07

共1个答案

小编典典

如何在fedora linux上安装mongodb和mongodb-server(已在f16和f17上验证)。所有命令均应在su会话中运行。

1)确保没有mongodb安装

# yum erase mongodb
# yum erase mongo-10gen  (if it is installed)

2)从fedora yum存储库安装

# yum --disablerepo=* --enablerepo=fedora,updates install mongodb mongodb-server

3)启动mongod(mongodb守护程序)

# systemctl start mongod.service

4)验证mongod正在运行

# systemctl status mongod.service
# tail /var/log/mongodb/mongodb.log
# nmap -p27017 localhost

或正在运行的客户端

# mongo
MongoDB shell version: 2.0.2
connecting to: test
> db.test.save( { a: 1 } )
> db.test.find()
{ "_id" : ObjectId("4fdf28f09d16204d66082fa3"), "a" : 1 }

5)自定义配置

# vim /etc/mongodb.conf
# systemctl restart mongod.service

6)使mongodb服务在启动时自动启动

# systemctl enable mongod.service

Fedora 18的更新

当systemd在运行缓慢或加载的计算机上首次启动时,mongod服务可能会在完成其初始化之前超时,并且systemd将服务标记为失败。

症状:

# journalctl -xn

-- Unit mongod.service has begun starting up.
10:38:43 local mongod[24558]: forked process: 24560
10:38:43 local mongod[24558]: all output going to: /var/log/mongodb/mongodb.log
10:40:13 local systemd[1]: mongod.service operation timed out. Terminating.
10:40:13 local systemd[1]: Failed to start High-performance, schema-free document-oriented database.
-- Subject: Unit mongod.service has failed

很容易治愈,重启服务:

# systemctl restart mongod.service

这样就可以成功完成初始化,并使守护程序保持运行状态。

2020-06-07