Question

I have the following mongod.service file:

[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target
Documentation=https://docs.mongodb.org/manual

[Service]
User=mongodb
Group=mongodb

ExecStart=/usr/bin/mongod --quiet --fork --config /etc/mongod.conf

# file size
LimitFSIZE=infinity

# cpu time
LimitCPU=infinity

# virtual memory size
LimitAS=infinity

# open files
LimitNOFILE=64000

# processes/threads
LimitNPROC=64000

# total threads (user+kernel)
TasksMax=infinity
TasksAccounting=false

# Recommended limits for for mongod as specified in
# http://docs.mongodb.org/manual/reference/ulimit/#recommended-settings

[Install]
WantedBy=multi-user.target

when I try to start the service using systemd it crashes and this is what i can see in the log file:

2018-01-18T14:20:07.380+0100 I CONTROL  [main] ***** SERVER RESTARTED *****
2018-01-18T14:20:07.403+0100 I CONTROL  [initandlisten] MongoDB starting : pid=6223 port=27017 dbpath=/var/lib/mongodb 64-bit host=atsjenkins
2018-01-18T14:20:07.403+0100 I CONTROL  [initandlisten] db version v3.6.2
2018-01-18T14:20:07.403+0100 I CONTROL  [initandlisten] git version: 489d177dbd0f0420a8ca04d39fd78d0a2c539420
2018-01-18T14:20:07.403+0100 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.2g  1 Mar 2016
2018-01-18T14:20:07.403+0100 I CONTROL  [initandlisten] allocator: tcmalloc
2018-01-18T14:20:07.403+0100 I CONTROL  [initandlisten] modules: none
2018-01-18T14:20:07.403+0100 I CONTROL  [initandlisten] build environment:
2018-01-18T14:20:07.403+0100 I CONTROL  [initandlisten]     distmod: ubuntu1604
2018-01-18T14:20:07.403+0100 I CONTROL  [initandlisten]     distarch: x86_64
2018-01-18T14:20:07.403+0100 I CONTROL  [initandlisten]     target_arch: x86_64
2018-01-18T14:20:07.403+0100 I CONTROL  [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1", port: 27017 }, processManagement: { fork: true, timeZoneInfo: "/usr/share/zoneinfo" }, storage: { dbPath: "/var/lib/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log", quiet: true } }
2018-01-18T14:20:07.404+0100 I -        [initandlisten] Detected data files in /var/lib/mongodb created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2018-01-18T14:20:07.404+0100 I STORAGE  [initandlisten]
2018-01-18T14:20:07.404+0100 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2018-01-18T14:20:07.404+0100 I STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
2018-01-18T14:20:07.404+0100 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=1463M,session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),statistics_log=(wait=0),verbose=(recovery_progress),
2018-01-18T14:20:07.617+0100 I STORAGE  [initandlisten] WiredTiger message [1516281607:617760][6223:0x7f5505f409c0], txn-recover: Main recovery loop: starting at 18/6144
2018-01-18T14:20:07.732+0100 I STORAGE  [initandlisten] WiredTiger message [1516281607:732326][6223:0x7f5505f409c0], txn-recover: Recovering log 18 through 19
2018-01-18T14:20:07.798+0100 I STORAGE  [initandlisten] WiredTiger message [1516281607:798817][6223:0x7f5505f409c0], txn-recover: Recovering log 19 through 19
2018-01-18T14:20:07.863+0100 I CONTROL  [initandlisten]
2018-01-18T14:20:07.863+0100 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-01-18T14:20:07.863+0100 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2018-01-18T14:20:07.863+0100 I CONTROL  [initandlisten]
2018-01-18T14:20:07.876+0100 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/var/lib/mongodb/diagnostic.data'
2018-01-18T14:20:07.877+0100 I NETWORK  [initandlisten] waiting for connections on port 27017
2018-01-18T14:21:02.288+0100 I CONTROL  [signalProcessingThread] got signal 15 (Terminated), will terminate after current cmd ends
2018-01-18T14:21:02.288+0100 I NETWORK  [signalProcessingThread] shutdown: going to close listening sockets...
2018-01-18T14:21:02.288+0100 I NETWORK  [signalProcessingThread] removing socket file: /tmp/mongodb-27017.sock
2018-01-18T14:21:02.289+0100 I FTDC     [signalProcessingThread] Shutting down full-time diagnostic data capture
2018-01-18T14:21:02.291+0100 I STORAGE  [signalProcessingThread] WiredTigerKVEngine shutting down
2018-01-18T14:21:02.357+0100 I STORAGE  [signalProcessingThread] shutdown: removing fs lock...
2018-01-18T14:21:02.357+0100 I CONTROL  [signalProcessingThread] now exiting
2018-01-18T14:21:02.358+0100 I CONTROL  [signalProcessingThread] shutting down with code:0

but starting it via terminal using the following command: sudo -u mongodb mongod --quiet --fork --config /etc/mongod.conf --port 27017 works. I am unable to figure out why this is happening at the moment so any hints/pointer will be appreciated. The following is the output from the version switch of the installed mongod:

$:~ mongod --version
db version v3.6.2
git version: 489d177dbd0f0420a8ca04d39fd78d0a2c539420
OpenSSL version: OpenSSL 1.0.2g  1 Mar 2016
allocator: tcmalloc
modules: none
build environment:
    distmod: ubuntu1604
    distarch: x86_64
    target_arch: x86_64

I'm on Ubuntu 16.04.3 LTS

Was it helpful?

Solution

You need to add Type=forking under [Service] header. It's service watchdog what kills mongod. Check this.

OTHER TIPS

I had the same issue after updating rhel 7.7 to 7.8. I had customized the location of the mongo PID file in mongod.conf before updating, but didn't changed it in the mongod.service file which was pointing to the default location. It seems systemd doesn't like that. Thanks @JJussi for the hint.

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top