Ubuntu – Cannot start mongo – Mongo killed

lxcmongodbUbuntu

I tried to migrate my Mongo installation from 14.04 to 16.04 using a new LXD Container.

I used the previous configuration file that can be found below.

mongod.cnf

# mongod.conf

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

# Where and how to store data.
storage:
  dbPath: /home/manager/mongo/data

#  engine:
#  mmapv1:
#    smallFiles: true

# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  path: /home/manager/mongo/log/mongod.log

# network interfaces
net:
  port: 27031
  bindIp: 127.0.0.1

processManagement:
  fork: true

setParameter:
   enableLocalhostAuthBypass: false

security:
  keyFile: /home/manager/mongo/mongodb-keyfile

#operationProfiling:

#replication:
#  replSetName: rs1

#sharding:

## Enterprise-Only Options:

#auditLog:

#snmp:

Here is my start service:

[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target

[Service]
User=manager
ExecStart=/usr/bin/mongod --quiet --config /home/manager/mongo/mongod.conf

[Install]
WantedBy=multi-user.target

And here is the error I get in the log file:

2016-06-03T10:39:30.657+0000 I CONTROL  [initandlisten] MongoDB starting : pid=807 port=27031 dbpath=/home/manager/mongo/data 64-bit host=mongo-rep-01
2016-06-03T10:39:30.657+0000 I CONTROL  [initandlisten] db version v3.2.6
2016-06-03T10:39:30.657+0000 I CONTROL  [initandlisten] git version: 05552b562c7a0b3143a729aaa0838e558dc49b25
2016-06-03T10:39:30.657+0000 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.2g-fips  1 Mar 2016
2016-06-03T10:39:30.657+0000 I CONTROL  [initandlisten] allocator: tcmalloc
2016-06-03T10:39:30.657+0000 I CONTROL  [initandlisten] modules: none
2016-06-03T10:39:30.657+0000 I CONTROL  [initandlisten] build environment:
2016-06-03T10:39:30.657+0000 I CONTROL  [initandlisten]     distmod: ubuntu1404
2016-06-03T10:39:30.657+0000 I CONTROL  [initandlisten]     distarch: x86_64
2016-06-03T10:39:30.657+0000 I CONTROL  [initandlisten]     target_arch: x86_64
2016-06-03T10:39:30.657+0000 I CONTROL  [initandlisten] options: { config: "/home/manager/mongo/mongod.conf", net: { bindIp: "127.0.0.1", port: 27031 }, processManagement: { fork: true }, security: { keyFile: "/home/manager/mongo/mongodb-keyfile" }, setParameter: { e$
2016-06-03T10:39:30.688+0000 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=18G,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idl$
2016-06-03T10:39:31.174+0000 I CONTROL  [initandlisten]
2016-06-03T10:39:31.175+0000 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2016-06-03T10:39:31.175+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2016-06-03T10:39:31.175+0000 I CONTROL  [initandlisten]
2016-06-03T10:39:31.175+0000 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-06-03T10:39:31.175+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2016-06-03T10:39:31.175+0000 I CONTROL  [initandlisten]
2016-06-03T10:39:31.177+0000 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/home/manager/mongo/data/diagnostic.data'
2016-06-03T10:39:31.177+0000 I NETWORK  [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
2016-06-03T10:39:31.178+0000 I CONTROL  [signalProcessingThread] got signal 15 (Terminated), will terminate after current cmd ends
2016-06-03T10:39:31.178+0000 I FTDC     [signalProcessingThread] Shutting down full-time diagnostic data capture
2016-06-03T10:39:31.185+0000 I NETWORK  [initandlisten] waiting for connections on port 27031
2016-06-03T10:39:31.185+0000 I CONTROL  [signalProcessingThread] now exiting
2016-06-03T10:39:31.185+0000 I NETWORK  [signalProcessingThread] shutdown: going to close listening sockets...
2016-06-03T10:39:31.185+0000 I NETWORK  [signalProcessingThread] closing listening socket: 6
2016-06-03T10:39:31.185+0000 I NETWORK  [signalProcessingThread] closing listening socket: 7
2016-06-03T10:39:31.186+0000 I NETWORK  [signalProcessingThread] removing socket file: /tmp/mongodb-27031.sock
2016-06-03T10:39:31.186+0000 I NETWORK  [signalProcessingThread] shutdown: going to flush diaglog...
2016-06-03T10:39:31.186+0000 I NETWORK  [signalProcessingThread] shutdown: going to close sockets...
2016-06-03T10:39:31.186+0000 I STORAGE  [signalProcessingThread] WiredTigerKVEngine shutting down
2016-06-03T10:39:32.336+0000 I STORAGE  [signalProcessingThread] shutdown: removing fs lock...
2016-06-03T10:39:32.336+0000 I CONTROL  [signalProcessingThread] dbexit:  rc: 0

And the status of the service:

root@mongo-rep-01:/home/manager/mongo# sudo systemctl status mongodb
● mongodb.service - High-performance, schema-free document-oriented database
   Loaded: loaded (/etc/systemd/system/mongodb.service; disabled; vendor preset: enabled)
   Active: inactive (dead)

Jun 03 10:17:17 mongo-rep-01 systemd[1]: Started High-performance, schema-free document-oriented database.
Jun 03 10:17:17 mongo-rep-01 mongod[643]: 2016-06-03T10:17:17.858+0000 W CONTROL  [main] Option: storage.smallFiles is deprecated. Please use storage.mmapv1.smallFiles instead.
Jun 03 10:17:17 mongo-rep-01 mongod[643]: about to fork child process, waiting until server is ready for connections.
Jun 03 10:17:17 mongo-rep-01 mongod[643]: forked process: 645
Jun 03 10:18:26 mongo-rep-01 systemd[1]: Started High-performance, schema-free document-oriented database.
Jun 03 10:18:26 mongo-rep-01 mongod[672]: about to fork child process, waiting until server is ready for connections.
Jun 03 10:18:26 mongo-rep-01 mongod[672]: forked process: 674
Jun 03 10:39:30 mongo-rep-01 systemd[1]: Started High-performance, schema-free document-oriented database.
Jun 03 10:39:30 mongo-rep-01 mongod[805]: about to fork child process, waiting until server is ready for connections.
Jun 03 10:39:30 mongo-rep-01 mongod[805]: forked process: 807

Best Answer

Based on the information I found here:

https://askubuntu.com/questions/787136/debugging-systemd-for-mongodb-3-2-on-ubuntu-16-04-sig-15-killing

It seemed that systemd was the source of "sig 15" termination indicated in the log file.

This can be fixed in the service definition by indicating that the process is a forking type:

[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target

[Service]
Type=forking
User=manager
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf

[Install]
WantedBy=multi-user.target

Alternatively try changing the processManagement value in your mongo.conf file:

processManagement:
  fork: false