Setting up MongoDB on Debian Wheezy 64Bit

MongoDB Logo

Here are the steps required for setting up MongoDB on Debian Wheezy. This is the manual guide since the official MongoDB packages provided by Debian are a little dusty. Don’t worry, the setup process is pretty straight forward. Let’s get started!

Import public key for package management tool apk

First you need to import the public key for your package management tool. In this case apk:

sudo apt-key adv –keyserver keyserver.ubuntu.com –recv 7F0CEB10

Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --secret-keyring /tmp/tmp.YX8vkOfNgq --trustdb-name /etc/apt//trustdb.gpg --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyring /etc/apt/trusted.gpg.d//debian-archive-jessie-automatic.gpg --keyring /etc/apt/trusted.gpg.d//debian-archive-jessie-security-automatic.gpg --keyring /etc/apt/trusted.gpg.d//debian-archive-jessie-stable.gpg --keyring /etc/apt/trusted.gpg.d//debian-archive-squeeze-automatic.gpg --keyring /etc/apt/trusted.gpg.d//debian-archive-squeeze-stable.gpg --keyring /etc/apt/trusted.gpg.d//debian-archive-wheezy-automatic.gpg --keyring /etc/apt/trusted.gpg.d//debian-archive-wheezy-stable.gpg --keyserver keyserver.ubuntu.com --recv 7F0CEB10
gpg: requesting key 7F0CEB10 from hkp server keyserver.ubuntu.com
gpg: key 7F0CEB10: public key "Richard Kreuter <richard@10gen.com>" imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)

Add MongoDB to package list

echo “deb http://repo.mongodb.org/apt/debian “$(lsb_release -sc)“/mongodb-org/3.0 main” | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list

Note that this command requires lsb_release.  In case you haven’t installed it do so by issuing the following command:

sudo apt-get install lsb_release

Refresh local package list

In order to check for your new package entry reload your local package list:

apt-get update

...
Get:1 http://repo.mongodb.org wheezy/mongodb-org/3.0 Release.gpg [490 B]
Hit https://repo.varnish-cache.org wheezy/varnish-4.0 amd64 Packages
Get:2 http://repo.mongodb.org wheezy/mongodb-org/3.0 Release [2,017 B]
Get:3 http://repo.mongodb.org wheezy/mongodb-org/3.0/main amd64 Packages [4,113 B]
Fetched 6,620 B in 1s (3,471 B/s)
Reading package lists... Done

Install MongoDB

Now it’s time to actually install MongoDB – hurray! We are going to install the latest stable release. In case you want to install a specific release version simply specify the release number.

Install latest stable MongoDB

sudo apt-get install -y mongodb-org

Install specific MongoDB version

Replace VERSION-XYZ with your desired MongoDB version, e.g. 3.0.4-rc0:

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

Check installation messages

Watch for the following installation messages to ensure that MongoDB was setup corectly:

Setting up mongodb-org-shell (3.0.3) ...
Setting up mongodb-org-server (3.0.3) ...
Adding system user `mongodb' (UID 111) ...
Adding new user `mongodb' (UID 111) with group `nogroup' ...
Not creating home directory `/home/mongodb'.
Adding group `mongodb' (GID 113) ...
Done.
Adding user `mongodb' to group `mongodb' ...
Adding user mongodb to group mongodb
Done.
[ ok ] Starting database: mongod.
Setting up mongodb-org-mongos (3.0.3) ...
Setting up mongodb-org-tools (3.0.3) ...
Setting up mongodb-org (3.0.3) ...

That’s it for the installation – Congratulations! By default, MongoDB listens on port 27017 for incoming requests. Please refer to /etc/mongod.conf for changing it, see section Configure MongoDB below

Run MongoDB

Once you’ve installed MongoDB here are the commands to control MongoDB.

Start MongoDB

sudo service mongod start

Verify status MongoDB

In order to verify the status of MongoDB have a look at log file located at

/var/log/mongodb/mongod.log

and watch out for the line

2015-06-14T10:21:05.027+0200 I NETWORK [initandlisten] waiting for connections on port 27017

Stop MongoDB

Like starting MongoDB use the service facilities to stop MongoDB:

sudo service mongod stop

Configure MongoDB

MongoDB can be configured using /etc/mongod.conf The file is pretty self-explanatory for the basic settings. Please refer to the Getting Started Guides for more information. Enjoy!

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.