0

Once you've setup the offical mongo PPA, Mongo's docs say that to install a specific version on Ubuntu, to run something like:

sudo apt-get install -y mongodb-org=3.6.2

I'd like to install version 3.4.10 on Ubuntu 16. I verified this version is available with:

apt-cache policy mongodb-org

which lists:

mongodb-org:
  Installed: 3.4.10
  Candidate: 3.4.11
  Version table:
     3.4.11 500
        500 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4/multiverse amd64 Packages
     3.4.10 500
        500 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4/multiverse amd64 Packages
        100 /var/lib/dpkg/status
     3.4.9 500
        500 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4/multiverse amd64 Packages
     3.4.8 500
        500 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4/multiverse amd64 Packages
     3.4.7 500
        500 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4/multiverse amd64 Packages
     3.4.6 500
        500 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4/multiverse amd64 Packages
     3.4.5 500
        500 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4/multiverse amd64 Packages
     3.4.4 500
        500 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4/multiverse amd64 Packages
     3.4.3 500
        500 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4/multiverse amd64 Packages
     3.4.2 500
        500 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4/multiverse amd64 Packages
     3.4.1 500
        500 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4/multiverse amd64 Packages
     3.4.0 500
        500 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4/multiverse amd64 Packages

so I tried running:

sudo apt-get install -y mongodb-org=3.4.10

but I received this nonsensical output:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  mongodb-org-mongos mongodb-org-server mongodb-org-shell mongodb-org-tools
The following NEW packages will be installed:
  mongodb-org mongodb-org-mongos mongodb-org-server mongodb-org-shell mongodb-org-tools
0 upgraded, 5 newly installed, 0 to remove and 1 not upgraded.
Need to get 3,522 B/67.0 MB of archives.
After this operation, 271 MB of additional disk space will be used.
Get:1 https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4/multiverse amd64 mongodb-org amd64 3.4.10 [3,522 B]
Fetched 3,522 B in 0s (8,901 B/s)       
Selecting previously unselected package mongodb-org-shell.
(Reading database ... 84310 files and directories currently installed.)
Preparing to unpack .../mongodb-org-shell_3.4.11_amd64.deb ...
Unpacking mongodb-org-shell (3.4.11) ...
Selecting previously unselected package mongodb-org-server.
Preparing to unpack .../mongodb-org-server_3.4.11_amd64.deb ...
Unpacking mongodb-org-server (3.4.11) ...
Selecting previously unselected package mongodb-org-mongos.
Preparing to unpack .../mongodb-org-mongos_3.4.11_amd64.deb ...
Unpacking mongodb-org-mongos (3.4.11) ...
Selecting previously unselected package mongodb-org-tools.
Preparing to unpack .../mongodb-org-tools_3.4.11_amd64.deb ...
Unpacking mongodb-org-tools (3.4.11) ...
Selecting previously unselected package mongodb-org.
Preparing to unpack .../mongodb-org_3.4.10_amd64.deb ...
Unpacking mongodb-org (3.4.10) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up mongodb-org-shell (3.4.11) ...
Setting up mongodb-org-server (3.4.11) ...
Setting up mongodb-org-mongos (3.4.11) ...
Setting up mongodb-org-tools (3.4.11) ...
Setting up mongodb-org (3.4.10) ...

Why does it say it's installing 3.4.11...only to finally say it's setting up 3.4.10? When I run /usr/bin/mongod --version it indeed shows it's installed the wrong version.

db version v3.4.11
git version: 34f5bec2c9d827d71828fe858167f89a28b29a2a
OpenSSL version: OpenSSL 1.0.2g  1 Mar 2016
allocator: tcmalloc
modules: none
build environment:
    distmod: ubuntu1604
    distarch: x86_64
    target_arch: x86_64

What am I doing wrong?

1

Apparently, to install a specific version, you need to specify not just the version of the main package, but also the version of all package dependencies. Otherwise apt-get assumes you want the most recent versions, of the dependencies...which require the most recent version of your main package, causing it to ignore your specified version. When I specified 3.4.10 for all the various mongo-org packages like:

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

then it correctly installed 3.4.10.

1

As i am seeing you have type the syntax like that

sudo apt-get install -y mongodb-org=3.6.2

Here i would like to say that if you want to install MongoDB version from PPA(Personal Package Archives) for Ubuntu then you can simply type mongodb-org. No need to mention as like

sudo apt-get install -y mongodb-org=3.4.10

Because PPA is nothing but a non standard software/updates. So, always it take update version from their respective vendor organization, like that

sudo apt-get install -y mongodb-org

In your case you want to install a specific version then definitely you have to define the version number (like MongoDB Version 3.4.10)

I am write down the simple steps to install MongoDB 3.4 in Ubuntu 16.04.

1) First we will import the MongoDB GPG public key in our system using following command

$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6

The Ubuntu package management tools (i.e. dpkg and apt) ensure package consistency and authenticity by requiring that distributors sign packages with GPG keys.

2) Create a MongoDB list file in /etc/apt/sources.list.d/ with this command:

For Ubuntu 16.04:

$ echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-3.4.list

3) Now that the MongoDB repository has been added, use following commands to install MongoDB in your systems.

Suppose that here in your case you want to install the specific version of MongoDB like 3.4.10 , then the command would be as mention below

$ sudo apt-get update
$ apt-get install mongodb-org=3.4.1 mongodb-org-server=3.4.1 mongodb-org-shell=3.4.1 mongodb-org-mongos=3.4.1 mongodb-org-tools=3.4.10

Note: - To installing the particular version repository, you make sure that you have run the $ sudo apt-get update.

To install update stable version of MongoDB

$ sudo apt-get update
$ sudo apt-get install mongodb-org

4) Start MongoDB and add it as service to be started at boot time:

For Ubuntu 16.04:

$ sudo systemctl start mongod
$ sudo systemctl enable mongod

5) Finally use the below command to check installed MongoDB version on your system

Type in the mongo shell command such as

$ mongod --version 

You shall get the your specific installation of MongoDB version details.

Most Important : The unofficial mongodb package provided by Ubuntu is not maintained by MongoDB. You should always use the official MongoDB mongodb-org packages, which are kept up-to-date with the most recent major and minor MongoDB releases.

For further your ref Here and Here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.