Mongo守护进程不能通过服务mongod启动

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

问题首先运行mongod服务:

# service mongod start

我得到了以下几点:

Rather than invoking init scripts through /etc/init.d,use the service(8) utility,eg 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,eg stop mongod ; start mongod. The restart(8) utility is also available.

我试过这个:

在Docker容器之间共享预编译的资产

Docker&nginx操作不允许

Docker容器在Mac上将端口暴露给主机时遇到麻烦

电脑睡眠后Docker无法访问

如何在CentOS 6.5中安装docker 1.9+?

# start mongod

但没有输出。

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

ls /var/log/mongodb -a #empty

好吧,接下来我尝试启动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

好吧,谷歌search后,我检查(所有答案来自Mongodb在Linux服务器和https://wiki.archlinux.org/index.php/MongoDB (节疑难解答 ),但仍然没有得到。

只有当我在后台直接运行mongod时, mongo shell才起作用:

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 ...

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

盐:在一个主机上的几个奴才?

请求将nginx反向代理挂起到docker上的ASP.NET 5 Web应用程序

如何生成主机唯一ID?

Pyqtdocker在窗口最小化和恢复时隐藏

我如何使用容器的内部IP地址作为Docker中的环境variables

Docker容器通常没有一个完整的初始化系统,与Docker容器中的新贵交互不起作用。 (理论上这是可能的,但是它击败了重量轻的目的)

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

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

另外,由于您正在使用交互式泊坞窗容器运行安装命令,所以只要考虑到docker,shell解释程序就是单个命令。 一旦进入交互式会话,您可以在后台运行mongod(如您所做的那样)并启动mongo客户端会话。

另一种方法是将这些指令作为Dockerfile的一部分运行。 你可以参考mongodb的例子 。

您可能还想要考虑一些已经在Docker Hub中发布的官方mongo db镜像:

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

相关文章

引言 本文从Linux小白的视角, 在CentOS 7.x服务器上搭建一个...
引言: 多线程编程/异步编程非常复杂,有很多概念和工具需要...
一. 宏观概念 ASP.NET Core Middleware是在应用程序处理管道...
背景 在.Net和C#中运行异步代码相当简单,因为我们有时候需要...
HTTP基本认证 在HTTP中,HTTP基本认证(Basic Authenticatio...
1.Linq 执行多列排序 OrderBy的意义是按照指定顺序排序,连续...