Mongo守护进程不运行服务mongod启动 [英] Mongo daemon doesn't run by service mongod start

查看:792
本文介绍了Mongo守护进程不运行服务mongod启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我通过阅读本页面安装了mongodb软件包( http: //docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/ )。
我使用docker和ubuntu 14.04映像来部署我的服务器。

Recently I installed mongodb package by reading this page (http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/). I use docker and ubuntu 14.04 image to deploy my server.

首先运行 mongod 服务,问题开始: p>

The problems start by first running the mongod service:

# service mongod start

我得到以下内容:

Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mongod restart

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the stop(8) and then start(8) utilities,
e.g. stop mongod ; start mongod. The restart(8) utility is also available.

我已经尝试过:

# start mongod

但没有输出。

接下来我想检查日志,但没有日志!

Next I wanted to check the log, but there is no log!

ls /var/log/mongodb -a #empty

好的,接下来我试着开始 shell:

Ok, next I tried to start mongo shell:

# mongo
2014-08-12T17:42:44.431+0000 warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2014-08-12T17:42:44.432+0000 Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146
exception: connect failed

好的,在谷歌搜索之后,我检查了(赞美) Mongodb在linux服务器和< a href =https://wiki.archlinux.org/index.php/MongoDB =nofollow noreferrer> https:// wi ki.archlinux.org/index.php/MongoDB (疑难解答),但仍然没有。

Ok, after googling I checked (applaied) all answers from Mongodb in linux server and https://wiki.archlinux.org/index.php/MongoDB (section Troubleshooting), but still get nothing.

> mongo shell只有当我在后台直接运行 mongod 时,才有效:

The mongo shell works only when I run mongod directly in background:

mongod --verbose &

[DataFileSync] BackgroundJob starting: DataFileSync
shardKeyTest passed
isInRangeTest passed
shardObjTest passed
[initandlisten] MongoDB starting : pid=451 port=27017 dbpath=/data/db 64-bit host=a9d816faea4c
[initandlisten] db version v2.6.4
[initandlisten] git version: 3a830be0eb92d772aa855ebb711ac91d658ee910
[initandlisten] build info: Linux build7.nj1.10gen.cc 2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Jan 3 21:39:27 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49
[initandlisten] allocator: tcmalloc
[initandlisten] options: { systemLog: { verbosity: 1 } }
[initandlisten] flushing directory /data/db
[initandlisten] journal dir=/data/db/journal
[initandlisten] recover : no journal files present, no recovery needed
[initandlisten] flushing directory /data/db/journal
[initandlisten] flushing directory /data/db/journal
[initandlisten] opening db:  local
[initandlisten] enter repairDatabases (to check pdfile version #)
[initandlisten]     local
[initandlisten] done repairDatabases
[initandlisten] opening db:  admin
[initandlisten] query admin.system.roles planSummary: EOF ntoreturn:0 ntoskip:0 keyUpdates:0 numYields:0 locks(micros) W:119 r:106 nreturned:0 reslen:20 0ms
[ClientCursorMonitor] BackgroundJob starting: ClientCursorMonitor
[PeriodicTaskRunner] BackgroundJob starting: PeriodicTaskRunner
[TTLMonitor] BackgroundJob starting: TTLMonitor
[initandlisten] fd limit hard:1048576 soft:524288 max conn: 419430
[IndexRebuilder] BackgroundJob starting: IndexRebuilder
[IndexRebuilder] opening db:  local
[initandlisten] create collection local.startup_log { size: 10485760, capped: true }
[initandlisten] command local.$cmd command: create { create: "startup_log", size: 10485760, capped: true } ntoreturn:1 keyUpdates:0 numYields:0  reslen:75 0ms
[initandlisten] insert local.startup_log ninserted:1 keyUpdates:0 numYields:0  0ms
[initandlisten] waiting for connections on port 27017
[IndexRebuilder] checking complete2014-08-12T17:48:29.837+0000 [DataFileSync] BackgroundJob starting: DataFileSync

现在我有以下内容:

/var/lib/mongodb (mongodb:mongodb) empty
/var/log/mongodb (mongodb:nogroup) empty
/data/db (mongo:nogroup) #useless

# mongod.conf
dbpath=/var/lib/mongodb
logpath=/var/log/mongodb/mongod.log
logappend=true
port = 27017
bind_ip = 0.0.0.0
...

这里发生了什么?我绝对困惑(

What's going on here? I'm absolutely confused (

推荐答案

Docker容器通常没有一个完整的init系统,与upstart的交互将无法在(理论上可能的,但是它打败了轻量级堆栈的目的)

Docker containers typically does not have a full init system and interaction with upstart will not work inside a docker container. (In theory it is possible, but it defeats the purposes of having light weight stack)

这意味着你启动一个docker容器,它会运行单个命令/ usr / bin / mongod

What this implies is that you start a docker container, it would run a single command "/usr/bin/mongod"

在docker容器内运行mongodb的示例:
https://docs.docker.com/engine/examples/mongodb/

Example of running mongodb inside a docker container: https://docs.docker.com/engine/examples/mongodb/

此外,由于您使用交互式Docker容器运行安装命令,因此您的shell解释器是单个命令,只要考虑到docker。一旦进入交互式会话,您可以在后台运行mongod(和您一样)并启动mongo客户端会话。

Also since you are running installation commands using an interactive docker container, your shell interpreter is the single command as far as docker is considered. Once in interactive session, you can run mongod in background (As you did) and start mongo client session.

另一种方式是作为一部分运行这些指令的 Dockerfile 。您可以参考 mongodb示例

Another way would be to run these instructions as part of Dockerfile. You can refer to mongodb example.

您可能还想考虑已在docker hub中发布的一些官方mongo数据库映像:

You might also want to consider some of the official mongo db images already published in docker hub:

https://registry.hub.docker.com/_/mongo/

这篇关于Mongo守护进程不运行服务mongod启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆