Details
-
Bug
-
Resolution: Won't Do
-
Major - P3
-
3.2.9, 3.4.2
-
Server Development Platform
-
ALL
-
Description
Hi,
On a Debian Jessie fresh install, mongodb service is not enabled with systemd, thus it does not start after installation or boot time.
user@sandbox:~$ systemctl list-unit-files --type=service |grep mongo
|
mongod.service disabled
|
The package mongodb-org-server comes with the mongod.service file :
dpkg -L mongodb-org-server
|
/.
|
------8<----------------
|
/lib
|
/lib/systemd
|
/lib/systemd/system
|
/lib/systemd/system/mongod.service
|
But the postinst script of the package does not call for systemctl to enable this service :
#!/bin/sh
|
# postinst script for mongodb
|
#
|
# see: dh_installdeb(1)
|
|
|
set -e
|
|
|
# summary of how this script can be called:
|
# * <postinst> `configure' <most-recently-configured-version>
|
# * <old-postinst> `abort-upgrade' <new version>
|
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
|
# <new-version>
|
# * <postinst> `abort-remove'
|
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
|
# <failed-install-package> <version> `removing'
|
# <conflicting-package> <version>
|
# for details, see http://www.debian.org/doc/debian-policy/ or
|
# the debian-policy package
|
|
|
|
|
case "$1" in
|
configure)
|
# create a mongodb group and user
|
if ! getent passwd mongodb >/dev/null 2>&1; then
|
adduser --system --no-create-home mongodb
|
addgroup --system mongodb
|
adduser mongodb mongodb
|
fi
|
|
|
# create db -- note: this should agree with dbpath in mongod.conf
|
mkdir -p /var/lib/mongodb
|
chown -R mongodb:mongodb /var/lib/mongodb
|
|
|
# create logdir -- note: this should agree with logpath in mongod.conf
|
mkdir -p /var/log/mongodb
|
chown -R mongodb:mongodb /var/log/mongodb
|
;;
|
|
|
abort-upgrade|abort-remove|abort-deconfigure)
|
;;
|
|
|
*)
|
echo "postinst called with unknown argument \`$1'" >&2
|
exit 1
|
;;
|
esac
|
|
|
# dh_installdeb will replace this with shell code automatically
|
# generated by other debhelper scripts.
|
|
|
# Automatically added by dh_installinit
|
if [ -x "/etc/init.d/mongod" ]; then
|
update-rc.d mongod defaults >/dev/null
|
invoke-rc.d mongod start || exit $?
|
fi
|
# End automatically added section
|
|
|
|
|
exit 0
|
It only tests for the existence of sysvinit script, not for the systemd one.
This lead to mongod not running after installation or system reboot on Debian Jessie and perhaps on other systems.
You might consider adding the same thing for systemd in the postinst script, like :
+if [ -f "/lib/systemd/system/mongod.service" ]; then
|
+ systemctl --system daemon-reload >/dev/null || true
|
+ systemctl enable mongod.service >/dev/null
|
+ systemctl start mongod.service|| exit $?
|
+fi
|
Things are getting worse while removing mongodb-org-server package, the mongod service is not stopped while it is removed :
user@sandbox:~$ sudo apt-get remove --purge mongodb-org-server
|
Reading package lists... Done
|
Building dependency tree
|
Reading state information... Done
|
The following packages were automatically installed and are no longer required:
|
mongodb-org-mongos mongodb-org-shell mongodb-org-tools
|
Use 'apt-get autoremove' to remove them.
|
The following packages will be REMOVED:
|
mongodb-org* mongodb-org-server*
|
0 upgraded, 0 newly installed, 2 to remove and 22 not upgraded.
|
After this operation, 54.5 MB disk space will be freed.
|
Do you want to continue? [Y/n]
|
(Reading database ... 40192 files and directories currently installed.)
|
Removing mongodb-org (3.4.2) ...
|
Purging configuration files for mongodb-org (3.4.2) ...
|
dpkg: warning: while removing mongodb-org, directory '/var/lib/mongodb' not empty so not removed
|
Removing mongodb-org-server (3.4.2) ...
|
Purging configuration files for mongodb-org-server (3.4.2) ...
|
Processing triggers for man-db (2.7.0.2-5) ...
|
user@sandbox:~$ mongo
|
MongoDB shell version v3.4.2
|
connecting to: mongodb://127.0.0.1:27017
|
MongoDB server version: 3.4.2
|
Server has startup warnings:
|
2017-02-17T15:14:31.249+0100 I STORAGE [initandlisten]
|
2017-02-17T15:14:31.249+0100 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
|
2017-02-17T15:14:31.249+0100 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
|
2017-02-17T15:14:31.917+0100 I CONTROL [initandlisten]
|
2017-02-17T15:14:31.917+0100 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
|
2017-02-17T15:14:31.917+0100 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
|
2017-02-17T15:14:31.917+0100 I CONTROL [initandlisten]
|
2017-02-17T15:14:31.917+0100 I CONTROL [initandlisten]
|
2017-02-17T15:14:31.917+0100 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
|
2017-02-17T15:14:31.917+0100 I CONTROL [initandlisten] ** We suggest setting it to 'never'
|
2017-02-17T15:14:31.917+0100 I CONTROL [initandlisten]
|
>
|
|
The prerm script of the package is lacking the stop action for systemd and manage only sysvinit script :
cat prerm
|
#!/bin/sh
|
set -e
|
# Automatically added by dh_installinit
|
if [ -x "/etc/init.d/mongod" ]; then
|
invoke-rc.d mongod stop || exit $?
|
fi
|
# End automatically added section
|
You might add something like this to stop the service and disable it before removing the file /lib/systemd/system/mongod.service (which actually do a broken link on the sytem) :
+if [ -f "/lib/systemd/system/mongod.service" ]; then
|
+ systemctl stop mongod.service|| exit $?
|
+ systemctl disable mongod.service > /dev/null
|
+fi
|
And, actually the postrm script seems to be fine.
I have seen this issue on 3.2.9 version and 3.4.2 version of mongodb-org-server package on Debian Jessie. It should affect every version between them.
Regards.
F.
Attachments
Issue Links
- is duplicated by
-
SERVER-28027 mongod service keeps running even after packages get removed on Debian/Ubuntu
-
- Closed
-