1

It seems that after upgrading to Ubuntu/ Kubuntu 18.04 has broken my MongoDB server.

I have tried to reinstall Mongo but I still can't start it as before:

$ sudo apt-get install mongodb-server
$ mongo --version
MongoDB shell version v3.6.3
git version: 9586e557d54ef70f9ca4b43c26892cd55257e1a5
OpenSSL version: OpenSSL 1.1.0h  27 Mar 2018
allocator: tcmalloc
modules: none
build environment:
    distarch: x86_64
    target_arch: x86_64

The status:

$ sudo service mongodb status
● mongodb.service - An object/document-oriented database
   Loaded: loaded (/lib/systemd/system/mongodb.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sun 2018-10-07 14:30:40 BST; 17s ago
     Docs: man:mongod(1)
  Process: 5925 ExecStart=/usr/bin/mongod --unixSocketPrefix=${SOCKETPATH} --config ${CONF} $DAEMON_OPTS (code=exited, status=62)
 Main PID: 5925 (code=exited, status=62)

Oct 07 14:30:38 lau-desktop systemd[1]: Started An object/document-oriented database.
Oct 07 14:30:40 lau-desktop systemd[1]: mongodb.service: Main process exited, code=exited, status=62/n/a
Oct 07 14:30:40 lau-desktop systemd[1]: mongodb.service: Failed with result 'exit-code'.

Any ideas?

EDIT:

When I tried to install mongo 4, I get the error:

Preparing to unpack .../mongodb-org-server_4.0.3_amd64.deb ...
Unpacking mongodb-org-server (4.0.3) ...
dpkg: error processing archive /var/cache/apt/archives/mongodb-org-server_4.0.3_amd64.deb (--unpack):
 trying to overwrite '/usr/bin/mongod', which is also in package mongodb-server-core 1:3.6.3-0ubuntu1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Preparing to unpack .../mongodb-org-mongos_4.0.3_amd64.deb ...
Unpacking mongodb-org-mongos (4.0.3) ...
dpkg: error processing archive /var/cache/apt/archives/mongodb-org-mongos_4.0.3_amd64.deb (--unpack):
 trying to overwrite '/usr/bin/mongos', which is also in package mongodb-server-core 1:3.6.3-0ubuntu1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Preparing to unpack .../mongodb-org-tools_4.0.3_amd64.deb ...
Unpacking mongodb-org-tools (4.0.3) ...
dpkg: error processing archive /var/cache/apt/archives/mongodb-org-tools_4.0.3_amd64.deb (--unpack):
 trying to overwrite '/usr/bin/bsondump', which is also in package mongo-tools 3.6.3-0ubuntu1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/mongodb-org-server_4.0.3_amd64.deb
 /var/cache/apt/archives/mongodb-org-mongos_4.0.3_amd64.deb
 /var/cache/apt/archives/mongodb-org-tools_4.0.3_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

EDIT 2:

$ sudo apt upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies.
 mongodb-org : Depends: mongodb-org-server but it is not installed
               Depends: mongodb-org-mongos but it is not installed
               Depends: mongodb-org-tools but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

EDIT 3:

$ mongo --versionMongoDB shell version v4.0.3
git version: 7ea530946fa7880364d88c8d8b6026bbc9ffa48c
OpenSSL version: OpenSSL 1.1.0h  27 Mar 2018
allocator: tcmalloc
modules: none
build environment:
    distmod: ubuntu1804
    distarch: x86_64
    target_arch: x86_64

$ sudo service mongodb status
● mongodb.service
   Loaded: masked (/dev/null; bad)
   Active: failed (Result: exit-code) since Sun 2018-10-07 15:12:14 BST; 1h 7min ago
 Main PID: 2232 (code=exited, status=62)

Oct 07 15:12:13 lau-desktop systemd[1]: Started An object/document-oriented database.
Oct 07 15:12:14 lau-desktop systemd[1]: mongodb.service: Main process exited, code=exited, status=62/n/a
Oct 07 15:12:14 lau-desktop systemd[1]: mongodb.service: Failed with result 'exit-code'.
Run
  • 2,748

2 Answers2

5

Following the guide from Mongo official site, I got it fixed.

Step 1:

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv E52529D4

Step 2:

echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list

Step 3:

sudo apt-get update

Step 4:

sudo apt-get install -y mongodb-org=4.0.2 mongodb-org-server=4.0.2 mongodb-org-shell=4.0.2 mongodb-org-mongos=4.0.2 mongodb-org-tools=4.0.2

Step 5:

sudo service mongod start

Step 6:

sudo service mongod status
● mongod.service - High-performance, schema-free document-oriented database
   Loaded: loaded (/etc/systemd/system/mongod.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2018-10-07 17:06:28 BST; 4min 24s ago
 Main PID: 27797 (mongod)
    Tasks: 26 (limit: 4915)
   CGroup: /system.slice/mongod.service
           └─27797 /usr/bin/mongod --quiet --config /etc/mongod.conf

Oct 07 17:06:28 lau-desktop systemd[1]: Started High-performance, schema-free document-oriented database.
Oct 07 17:06:28 lau-desktop mongod[27797]: 2018-10-07T17:06:28.337+0100 I CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS
lines 1-10/10 (END)
Terrance
  • 43,712
Run
  • 2,748
1

I also faced the same issue. The accepted answer did not worked for me, as I was trying to install version 4.0.5. I like to share how I solved the problem.

From the error message, I learnt that, apt is trying overwrite /usr/bin/bsondump of version 3.6.3, with the latest version(at the time of writing this) 4.0.5. Earlier, I did removed, previously install mongodb version 3.6.3. Some how, mongo-tools package was left.

So, I simply needed to remove mongo-tools@3.6.3. But, as the installation of mongodb@4.0.5 did not completed successfully, I had to reset apt before, I can do anything with apt.

This command undid the broken package installation.

sudo dpkg --remove --force-remove-reinstreq mongodb-org

Then, I simply ran following commands to remove mongo-tools@3.6.3

sudo apt update # to refresh apt
sudo apt remove mongo-tools # to remove mongo-tools 3.6.3

Finally, I re-ran the following command to install latest mongodb

sudo apt-get install -y mongodb-org

It worked!

explorer
  • 111