[Nix-dev] restarting a mongodb

stewart mackenzie setori88 at gmail.com
Wed Jul 8 07:13:29 CEST 2015


Hello all,

So rebuilding our database server with this bit in our config:

```

                    services = {
                        mongodb = {
                            enable = true;
                            bind_ip = "0.0.0.0";
                            dbpath = "/mongo/db";
                        };
                    };
                    fileSystems."/mongo" = {
                        device = "/dev/xvdb";
                        fsType = "ext4";
                        autoFormat = true;
                    };
```

resulted in this issue:

```

starting the following units: cron.service, fetch-ec2-data.service,
kmod-static-nodes.service, network-local-commands.service,
network-setup.service, nix-daemon.service, nscd.service, ntpd.service,
print-host-key.service, rngd.service, systemd-logind.service,
systemd-modules-load.service, systemd-sysctl.service,
systemd-tmpfiles-clean.timer, systemd-tmpfiles-setup-dev.service,
systemd-udev-settle.service, systemd-udev-trigger.service,
systemd-udevd.service, systemd-vconsole-setup.service
the following new units were started: mongo-bak.mount, mongo.mount,
postfix.service
warning: the following units failed: mongodb.service

● mongodb.service - MongoDB server
   Loaded: loaded
(/nix/store/5kvf87w82nk9kfh5p2iamdq7gzc9nfr3-unit-mongodb.service/mongodb.service)
   Active: failed (Result: exit-code) since Wed 2015-07-08 12:38:15
HKT; 12ms ago
  Process: 15082
ExecStart=/nix/store/ifx5xm0m625gv003v1zsn15pr447zwmf-mongodb-2.6.5/bin/mongod
--quiet --config
/nix/store/18ahs474r1gbpkacy22rl6vy7q8jwxfq-mongodb.conf (code=exited,
status=100)
  Process: 15041
ExecStartPre=/nix/store/sig4djkyinm552svg58ryzvs0apxjbf2-unit-script/bin/mongodb-pre-start
(code=exited, status=0/SUCCESS)

Jul 08 12:38:15 ip-172-30-0-78.ap-southeast-1.compute.internal
mongod.27017[15137]: [initandlisten] warning caught exception
(assertion src/mongo/db/dur_journal.cpp:362) in preallocateFiles,
continuing
Jul 08 12:38:15 ip-172-30-0-78.ap-southeast-1.compute.internal
mongod.27017[15137]: [initandlisten] exception in initAndListen: 13516
couldn't open file /mongo/db/journal/j._0 for writing errno:2 No such
file or directory, terminating
Jul 08 12:38:15 ip-172-30-0-78.ap-southeast-1.compute.internal
mongod.27017[15137]: [initandlisten] dbexit:
Jul 08 12:38:15 ip-172-30-0-78.ap-southeast-1.compute.internal
mongod.27017[15137]: [initandlisten] shutdown: going to close
listening sockets...
Jul 08 12:38:15 ip-172-30-0-78.ap-southeast-1.compute.internal
mongod.27017[15137]: [initandlisten] shutdown: going to flush
diaglog...
Jul 08 12:38:15 ip-172-30-0-78.ap-southeast-1.compute.internal
mongod[15082]: ERROR: child process failed, exited with error number
100
Jul 08 12:38:15 ip-172-30-0-78.ap-southeast-1.compute.internal
systemd[1]: mongodb.service: control process exited, code=exited
status=100
Jul 08 12:38:15 ip-172-30-0-78.ap-southeast-1.compute.internal
systemd[1]: Failed to start MongoDB server.
Jul 08 12:38:15 ip-172-30-0-78.ap-southeast-1.compute.internal
systemd[1]: Unit mongodb.service entered failed state.
Jul 08 12:38:15 ip-172-30-0-78.ap-southeast-1.compute.internal
systemd[1]: mongodb.service failed.
warning: error(s) occured while switching to the new configuration
```

It seems the mongo db directory didn't exist yet as it was probably
still formatting.

Please note the "autoFormat = true;" in the script.

We ran the script immediately afterwards and it ran without failures.

As this is the database (which we're deprecating for datomic) it's important.
How do I avoid such errors in future?

Thanks in advance
Stewart


More information about the nix-dev mailing list