每次我尝试使用本地环境引导 juju 时,启动juju-db-braiam-local
脚本都会失败,如下所示:
$ sudo juju --debug --verbose bootstrap
2013-10-20 02:28:53 INFO juju.provider.local environprovider.go:32 opening environment "local"
2013-10-20 02:28:53 DEBUG juju.provider.local environ.go:210 found "10.0.3.1" as address for "lxcbr0"
2013-10-20 02:28:53 DEBUG juju.provider.local environ.go:234 checking 10.0.3.1:8040 to see if machine agent running storage listener
2013-10-20 02:28:53 DEBUG juju.provider.local environ.go:237 nope, start some
2013-10-20 02:28:53 DEBUG juju.environs.tools storage.go:87 Uploading tools for [raring precise]
2013-10-20 02:28:53 DEBUG juju.environs.tools build.go:109 looking for: juju
2013-10-20 02:28:53 DEBUG juju.environs.tools build.go:150 checking: /usr/bin/jujud
2013-10-20 02:28:53 INFO juju.environs.tools build.go:156 found existing jujud
2013-10-20 02:28:53 INFO juju.environs.tools build.go:166 target: /tmp/juju-tools243949228/jujud
2013-10-20 02:28:53 DEBUG juju.environs.tools build.go:217 forcing version to 1.14.1.1
2013-10-20 02:28:53 DEBUG juju.environs.tools build.go:37 adding entry: &tar.Header{Name:"FORCE-VERSION", Mode:420, Uid:0, Gid:0, Size:8, ModTime:time.Time{sec:63517832933, nsec:278894120, loc:(*time.Location)(0x108fda0)}, Typeflag:0x30, Linkname:"", Uname:"ubuntu", Gname:"ubuntu", Devmajor:0, Devminor:0, AccessTime:time.Time{sec:63517832933, nsec:278894120, loc:(*time.Location)(0x108fda0)}, ChangeTime:time.Time{sec:63517832933, nsec:278894120, loc:(*time.Location)(0x108fda0)}}
2013-10-20 02:28:53 DEBUG juju.environs.tools build.go:37 adding entry: &tar.Header{Name:"jujud", Mode:493, Uid:0, Gid:0, Size:19179512, ModTime:time.Time{sec:63517832933, nsec:274894120, loc:(*time.Location)(0x108fda0)}, Typeflag:0x30, Linkname:"", Uname:"ubuntu", Gname:"ubuntu", Devmajor:0, Devminor:0, AccessTime:time.Time{sec:63517832933, nsec:274894120, loc:(*time.Location)(0x108fda0)}, ChangeTime:time.Time{sec:63517832933, nsec:274894120, loc:(*time.Location)(0x108fda0)}}
2013-10-20 02:28:55 INFO juju.environs.tools storage.go:106 built 1.14.1.1-raring-amd64 (4196kB)
2013-10-20 02:28:55 INFO juju.environs.tools storage.go:112 uploading 1.14.1.1-precise-amd64
2013-10-20 02:28:55 INFO juju.environs.tools storage.go:112 uploading 1.14.1.1-raring-amd64
2013-10-20 02:28:55 INFO juju.environs.tools tools.go:29 reading tools with major version 1
2013-10-20 02:28:55 INFO juju.environs.tools tools.go:34 filtering tools by version: 1.14.1.1
2013-10-20 02:28:55 INFO juju.environs.tools tools.go:37 filtering tools by series: precise
2013-10-20 02:28:55 DEBUG juju.environs.tools storage.go:41 reading v1.* tools
2013-10-20 02:28:55 DEBUG juju.environs.tools storage.go:61 found 1.14.1.1-precise-amd64
2013-10-20 02:28:55 DEBUG juju.environs.tools storage.go:61 found 1.14.1.1-raring-amd64
2013-10-20 02:28:55 INFO juju.environs.boostrap bootstrap.go:57 bootstrapping environment "local"
2013-10-20 02:28:55 INFO juju.environs.tools tools.go:29 reading tools with major version 1
2013-10-20 02:28:55 INFO juju.environs.tools tools.go:34 filtering tools by version: 1.14.1.1
2013-10-20 02:28:55 INFO juju.environs.tools tools.go:37 filtering tools by series: precise
2013-10-20 02:28:55 DEBUG juju.environs.tools storage.go:41 reading v1.* tools
2013-10-20 02:28:55 DEBUG juju.environs.tools storage.go:61 found 1.14.1.1-precise-amd64
2013-10-20 02:28:55 DEBUG juju.environs.tools storage.go:61 found 1.14.1.1-raring-amd64
2013-10-20 02:28:55 DEBUG juju.provider.local environ.go:395 create mongo journal dir: /home/braiam/.juju/local/db/journal
2013-10-20 02:28:55 DEBUG juju.provider.local environ.go:401 generate server cert
2013-10-20 02:28:55 INFO juju.provider.local environ.go:421 installing service juju-db-braiam-local to /etc/init
2013-10-20 02:28:56 ERROR juju.provider.local environ.go:423 could not install mongo service: exec ["start" "juju-db-braiam-local"]: exit status 1 (start: Job failed to start)
2013-10-20 02:28:56 ERROR juju supercommand.go:282 command failed: exec ["start" "juju-db-braiam-local"]: exit status 1 (start: Job failed to start)
error: exec ["start" "juju-db-braiam-local"]: exit status 1 (start: Job failed to start)
造成这个错误的原因是什么以及如何解决?
答案1
TL;dr:您没有足够的可用空间。请在您的主分区中留出至少 500MB 的可用空间。
好吧,我开始四处寻找,发现脚本执行失败service juju-db-braiam-local start
。手动运行时也会失败。检查内容后我发现:
description "juju state database"
author "Juju Team <[email protected]>"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
normal exit 0
limit nofile 65000 65000
limit nproc 20000 20000
exec /usr/bin/mongod --auth --dbpath=/home/braiam/.juju/local/db --sslOnNormalPorts --sslPEMKeyFile '/home/braiam/.juju/local/server.pem' --sslPEMKeyPassword ignored --bind_ip 0.0.0.0 --port 37017 --noprealloc --syslog --smallfiles
根据错误代码,失败与exec
指令有关,因此我手动运行它。它显然写入系统日志,所以我找到了原因:
Oct 20 02:41:05 vm-2 mongod.37017[5159]: Sun Oct 20 02:41:05 [initandlisten] options: { auth: true, bind_ip: "0.0.0.0", dbpath: "/home/braiam/.juju/local/db", noprealloc: true, port: 37017, smallfiles: true, sslOnNormalPorts: true, sslPEMKeyFile: "/home/braiam/.juju/local/server.pem", sslPEMKeyPassword: "<password>", syslog: true }
Oct 20 02:41:05 vm-2 mongod.37017[5159]: Sun Oct 20 02:41:05 [initandlisten] journal dir=/home/braiam/.juju/local/db/journal
Oct 20 02:41:05 vm-2 mongod.37017[5159]: Sun Oct 20 02:41:05 [initandlisten] recover : no journal files present, no recovery needed
Oct 20 02:41:05 vm-2 mongod.37017[5159]: Sun Oct 20 02:41:05 [initandlisten]
Oct 20 02:41:05 vm-2 mongod.37017[5159]: Sun Oct 20 02:41:05 [initandlisten] ERROR: Insufficient free space for journal files
Oct 20 02:41:05 vm-2 mongod.37017[5159]: Sun Oct 20 02:41:05 [initandlisten] Please make at least 422MB available in /home/braiam/.juju/local/db/journal or use --smallfiles
Oct 20 02:41:05 vm-2 mongod.37017[5159]: Sun Oct 20 02:41:05 [initandlisten]
Oct 20 02:41:05 vm-2 mongod.37017[5159]: Sun Oct 20 02:41:05 [initandlisten] exception in initAndListen: 15926 Insufficient free space for journals, terminating
就是这样,显然 mongodb 没有读取脚本末尾的 --smallfiles... 很奇怪。释放 422MB 应该可以解决这个问题,但无论如何 mongodb 都应该能够启动。
进一步调查后,我发现 mongodb--smallfiles
在与其他参数一起使用时完全忽略了。我打开了一个错误报告对这个,解决这个问题的更简单的方法是提供更多的空间。