在 Ubuntu LXC 容器中安装 MongoDB。失败并显示“invoke-rc.d:initscript mongod,操作“启动”失败。”

在 Ubuntu LXC 容器中安装 MongoDB。失败并显示“invoke-rc.d:initscript mongod,操作“启动”失败。”

我无法在 Ubuntu LXC 容器中安装 mongodb。

我按照以下说明设置了 Ubuntu 14.10 主机:https://linuxcontainers.org/lxc/getting-started/

lxc-create --version
1.1.0

按照文档,我通过下载模板创建了虚拟机,并选择了 Ubuntu 14.10 amd64 来宾(尽管我在 14.04 amd64 上遇到了相同的行为):

我开始依恋它

lxc-start -n test0 && lxc-attach -n test0

在我运行的容器内

apt-get update && apt-get install mongodb

安装失败并显示以下输出:

...
Setting up mongodb-clients (1:2.6.3-0ubuntu5) ...
Setting up mongodb-server (1:2.6.3-0ubuntu5) ...
Adding system user `mongodb' (UID 101) ...
Adding new user `mongodb' (UID 101) with group `nogroup' ...
Not creating home directory `/var/lib/mongodb'.
Adding group `mongodb' (GID 105) ...
Done.
Adding user `mongodb' to group `mongodb' ...
Adding user mongodb to group mongodb
Done.
start: Job failed to start
invoke-rc.d: initscript mongodb, action "start" failed.
dpkg: error processing package mongodb-server (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mongodb:
 mongodb depends on mongodb-server (>= 1:2.4.1-2); however:
  Package mongodb-server is not configured yet.

dpkg: error processing package mongodb (--configure):
 dependency problems - leaving unconfigured
Processing triggers for libc-bin (2.19-10ubuntu2.3) ...
Processing triggers for ureadahead (0.100.0-16) ...
Errors were encountered while processing:
 mongodb-server
 mongodb
E: Sub-process /usr/bin/dpkg returned an error code (1)

使用 14.04 容器和 10gen 存储库会导致相同的错误:

start: Job failed to start
invoke-rc.d: initscript mongod, action "start" failed.
dpkg: error processing package mongodb-org-server (--configure):
 subprocess installed post-installation script returned error exit status 1
Setting up mongodb-org-mongos (3.0.0) ...
Setting up mongodb-org-tools (3.0.0) ...
dpkg: dependency problems prevent configuration of mongodb-org:
 mongodb-org depends on mongodb-org-server; however:
  Package mongodb-org-server is not configured yet.

df -h一些搜索表明该问题可能是由于磁盘空间不足引起的,但根据主机上的说法,可用空间超过15G 。

作为命令运行mongod告诉我它正在寻找 /data/db 路径。创建它将使我能够运行mongod,但运行service mongodb start会返回start: Job failed to start

我在几个不同的虚拟和物理主机上尝试过,总是出现相同的错误。

答案1

不久前,我在使用 Ubuntu 14.04 作为客户操作系统的 lxc 中遇到了类似的问题。我做了一些挖掘,结果发现limit nofile ...mongodb upstart job 中的指令以某种方式导致dpkg --configure对 mongodb-server 包的调用在 mongodb 安装后过程中失败退出。注释该行可以让安装过程继续并成功完成。

root@mongodb:~# apt install mongodb
...
Setting up mongodb-server (1:2.4.9-1ubuntu2) ...
start: Job failed to start
invoke-rc.d: initscript mongodb, action "start" failed.
dpkg: error processing package mongodb-server (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mongodb:
 mongodb depends on mongodb-server (>= 1:2.4.1-2); however:
  Package mongodb-server is not configured yet.

dpkg: error processing package mongodb (--configure):
 dependency problems - leaving unconfigured
Processing triggers for libc-bin (2.19-0ubuntu6.6) ...
Processing triggers for ureadahead (0.100.0-16) ...
Errors were encountered while processing:
 mongodb-server
 mongodb
E: Sub-process /usr/bin/dpkg returned an error code (1)

root@mongodb:~# sed -i -r 's/^limit nofile/#&/' /etc/init/mongodb.conf 
root@mongodb:~# apt install mongodb
Reading package lists... Done
Building dependency tree       
Reading state information... Done
mongodb is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] 
Setting up mongodb-server (1:2.4.9-1ubuntu2) ...
mongodb start/running, process 3447
Setting up mongodb (1:2.4.9-1ubuntu2) ...

root@mongodb:~# sed -i -r 's/^#limit nofile/limit nofile/' /etc/init/mongodb.conf
root@mongodb:~# initctl restart mongodb
mongodb start/running, process 3480

相关内容