Linux MongoDB 服务未在 Fedora 中运行

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11081822/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 06:55:13  来源:igfitidea点击:

MongoDB service not running in Fedora

linuxmongodbfedora

提问by QuirijnGB

Just installed a clean version of mongodb on Fedora 17 64-bit, but the Mongo service wont run.

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

I followed these instructionsduring installation

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

Running

跑步

service mongod start

results in

结果是

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

So I ran

所以我跑了

systemctl status mongod.service

which gives me

这给了我

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 logs in /var/log/mongo/mongod.logis empty

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

Thanks

谢谢

采纳答案by guido

How to install mongodb and mongodb-server on fedora linux (verified on f16 & f17). All commands are intended to be run in a su session.

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

1) make sure you have no mongodb installation lying around

1)确保你没有安装mongodb

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

2) install from fedora yum repository

2) 从 fedora yum 存储库安装

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

3) start mongod (mongodb daemon)

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

# systemctl start mongod.service

4) verify mongod is running

4) 验证 mongod 正在运行

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

or running client

或运行客户端

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

5) customize configuration

5)自定义配置

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

6) make mongodb service automatically start at boot

6)让mongodb服务开机自动启动

# systemctl enable mongod.service

Update for Fedora 18

Fedora 18 更新

When started for the first time by systemd on a slow or loaded machine, mongod service might timeout before finishing its initialization, with systemd flagging the service as failed.

当 systemd 在缓慢或加载的机器上第一次启动时,mongod 服务可能会在完成初始化之前超时,systemd 会将服务标记为失败。

Symptoms:

症状:

# 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

Very easy cure, restart the service:

很容易治愈,重启服务:

# systemctl restart mongod.service

this should finish the initialization successfully and leave the daemon in running state.

这应该成功完成初始化并使守护程序处于运行状态。

回答by ava_punksmash

I just had the same issue and in my case it was caused by installing mongodb following instructions of some websites using non-official repo. If you have the same issue and the answer above are not solving your problem, try uninstalling "mongodb-org" package and reinstalling it following the instructions of the official documentation : https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/

我刚刚遇到了同样的问题,在我的情况下,它是由使用非官方 repo 的某些网站的说明安装 mongodb 引起的。如果您有同样的问题并且上面的答案没有解决您的问题,请尝试按照官方文档的说明卸载“mongodb-org”包并重新安装:https: //docs.mongodb.com/manual/tutorial/install -mongodb-on-red-hat/

Remainder to uninstall package in fedora:

在 Fedora 中卸载软件包的剩余部分:

sudo dnf remove <package-name>