Closed nyetsche closed 10 years ago
Thank you for your feedback. Increasing the sleep time should work. But I'd like to find a way to ensure MongoDB is available in Dockerfiles of Microscaler and Asgard. --fork
option does not wait the daemon is ready. I found a Q&A about this: how to check if mongodb is up and ready to accept connections from bash script?. This might be helpful.
I added smallfiles = true
to the config file to ease this issue and reduce the seize of the image in 1427d6afa8. I believe this works. I checked how the option affects.
/var/log/mongodb/mongodb.log
with smallfiles = true
Wed Jun 18 17:01:02.632 [initandlisten] MongoDB starting : pid=9 port=27017 dbpath=/var/lib/mongodb 64-bit host=6578e5106a94
Wed Jun 18 17:01:02.633 [initandlisten] db version v2.4.9
Wed Jun 18 17:01:02.633 [initandlisten] git version: nogitversion
Wed Jun 18 17:01:02.633 [initandlisten] build info: Linux orlo 3.2.0-58-generic #88-Ubuntu SMP Tue Dec 3 17:37:58 UTC 2013 x86_64 BOOST_LIB_VERSION=1_54
Wed Jun 18 17:01:02.633 [initandlisten] allocator: tcmalloc
Wed Jun 18 17:01:02.633 [initandlisten] options: { bind_ip: "0.0.0.0", config: "/etc/mongodb.conf", dbpath: "/var/lib/mongodb", journal: "true", logappend: "true", logpath: "/var/log/mongodb/mongodb.log", port: 27017, smallfiles: "true" }
Wed Jun 18 17:01:02.646 [initandlisten] journal dir=/var/lib/mongodb/journal
Wed Jun 18 17:01:02.646 [initandlisten] recover : no journal files present, no recovery needed
Wed Jun 18 17:01:02.912 [initandlisten] preallocateIsFaster=true 3.36
Wed Jun 18 17:01:03.145 [initandlisten] preallocateIsFaster=true 3.04
Wed Jun 18 17:01:04.462 [initandlisten] preallocateIsFaster=true 3.92
Wed Jun 18 17:01:04.462 [initandlisten] preallocating a journal file /var/lib/mongodb/journal/prealloc.0
Wed Jun 18 17:01:04.943 [initandlisten] preallocating a journal file /var/lib/mongodb/journal/prealloc.1
Wed Jun 18 17:01:05.377 [initandlisten] preallocating a journal file /var/lib/mongodb/journal/prealloc.2
Wed Jun 18 17:01:05.818 [FileAllocator] allocating new datafile /var/lib/mongodb/local.ns, filling with zeroes...
Wed Jun 18 17:01:05.818 [FileAllocator] creating directory /var/lib/mongodb/_tmp
Wed Jun 18 17:01:05.827 [FileAllocator] done allocating datafile /var/lib/mongodb/local.ns, size: 16MB, took 0.007 secs
Wed Jun 18 17:01:05.828 [FileAllocator] allocating new datafile /var/lib/mongodb/local.0, filling with zeroes...
Wed Jun 18 17:01:05.829 [FileAllocator] done allocating datafile /var/lib/mongodb/local.0, size: 16MB, took 0.001 secs
Wed Jun 18 17:01:05.834 [websvr] admin web console waiting for connections on port 28017
Wed Jun 18 17:01:05.834 [initandlisten] waiting for connections on port 27017
5 seconds after starting mongod
, the size of /var/lib/mongodb
was 417M.
/var/log/mongodb/mongodb.log
without smallfiles = true
(default)
Wed Jun 18 17:02:17.438 [initandlisten] MongoDB starting : pid=10 port=27017 dbpath=/var/lib/mongodb 64-bit host=6578e5106a94
Wed Jun 18 17:02:17.438 [initandlisten] db version v2.4.9
Wed Jun 18 17:02:17.438 [initandlisten] git version: nogitversion
Wed Jun 18 17:02:17.438 [initandlisten] build info: Linux orlo 3.2.0-58-generic #88-Ubuntu SMP Tue Dec 3 17:37:58 UTC 2013 x86_64 BOOST_LIB_VERSION=1_54
Wed Jun 18 17:02:17.438 [initandlisten] allocator: tcmalloc
Wed Jun 18 17:02:17.438 [initandlisten] options: { bind_ip: "0.0.0.0", config: "/etc/mongodb.conf", dbpath: "/var/lib/mongodb", journal: "true", logappend: "true", logpath: "/var/log/mongodb/mongodb.log", port: 27017 }
Wed Jun 18 17:02:17.448 [initandlisten] journal dir=/var/lib/mongodb/journal
Wed Jun 18 17:02:17.448 [initandlisten] recover : no journal files present, no recovery needed
Wed Jun 18 17:02:17.721 [initandlisten] preallocateIsFaster=true 3.64
Wed Jun 18 17:02:17.997 [initandlisten] preallocateIsFaster=true 3.72
Wed Jun 18 17:02:19.353 [initandlisten] preallocateIsFaster=true 5.16
Wed Jun 18 17:02:19.353 [initandlisten] preallocating a journal file /var/lib/mongodb/journal/prealloc.0
Wed Jun 18 17:02:22.045 [initandlisten] preallocating a journal file /var/lib/mongodb/journal/prealloc.1
5 seconds after starting mongod
, the size of /var/lib/mongodb
was 1.7G.
You used a faster machine but it would take long time to allocate gigabytes of files.
Thanks. On a m3.large this built just fine with that commit. No need for an extra sleep (I think).
Thank you for your verification. Current fixed time wait is not perfect. I'd like to add more reliable way.
On an EC2 m3.xlarge EC2 instance, mongodb doesn't start in time for the user accounts below to connect to it, so the docker build fails. Increase the wait before connecting the docker image builds just fine.