MongoDB 3.2 Installation
1) Know your OS version & OS bit type with following commands to download the MongoDB packages.
[ root@dbversity.com #]more /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION=”Ubuntu 14.04.3 LTS”
[ root@dbversity.com #]
[ root@dbversity.com #]uname -a
Linux srinivas-HP-G62-Notebook-PC 3.19.0-42-generic#48~14.04.1-Ubuntu SMP Fri Dec 18 10:24:49 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
[ root@dbversity.com #]
2) Download the relavent package from the MongoDB Downloads site i.e., https://www.mongodb.org/downloads#production with Curl command as below.
[ root@dbversity.com #]pwd
/home/srinivas
[ root@dbversity.com #]
[ root@dbversity.com #]mkdir mongodb-3.2
[ root@dbversity.com #]cd mongodb-3.2/
[ root@dbversity.com #]pwd
/home/srinivas/mongodb-3.2
[ root@dbversity.com #]
[ root@dbversity.com #]curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1404-3.2.0.tgz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 72.3M 100 72.3M 0 0 86097 0 0:14:40 0:14:40 –:–:– 21197
[ root@dbversity.com #]
[ root@dbversity.com #]ll -lhtr
total 73M
drwxr-xr-x 34 srinivas srinivas 4.0K Dec 28 16:09 ../
drwxr-xr-x 2 root root 4.0K Dec 28 16:09 ./
-rw-r–r– 1 root root 73M Dec 28 16:24 mongodb-linux-x86_64-ubuntu1404-3.2.0.tgz
[ root@dbversity.com #]
3) Untar the binaries downloaded above as below.
[ root@dbversity.com #]tar -zxvf mongodb-linux-x86_64-ubuntu1404-3.2.0.tgz &
[1] 6685
[ root@dbversity.com #]mongodb-linux-x86_64-ubuntu1404-3.2.0/README
mongodb-linux-x86_64-ubuntu1404-3.2.0/THIRD-PARTY-NOTICES
mongodb-linux-x86_64-ubuntu1404-3.2.0/MPL-2
mongodb-linux-x86_64-ubuntu1404-3.2.0/GNU-AGPL-3.0
mongodb-linux-x86_64-ubuntu1404-3.2.0/bin/mongodump
mongodb-linux-x86_64-ubuntu1404-3.2.0/bin/mongorestore
mongodb-linux-x86_64-ubuntu1404-3.2.0/bin/mongoexport
mongodb-linux-x86_64-ubuntu1404-3.2.0/bin/mongoimport
mongodb-linux-x86_64-ubuntu1404-3.2.0/bin/mongostat
mongodb-linux-x86_64-ubuntu1404-3.2.0/bin/mongotop
mongodb-linux-x86_64-ubuntu1404-3.2.0/bin/bsondump
mongodb-linux-x86_64-ubuntu1404-3.2.0/bin/mongofiles
mongodb-linux-x86_64-ubuntu1404-3.2.0/bin/mongooplog
mongodb-linux-x86_64-ubuntu1404-3.2.0/bin/mongoperf
mongodb-linux-x86_64-ubuntu1404-3.2.0/bin/mongosniff
mongodb-linux-x86_64-ubuntu1404-3.2.0/bin/mongod
mongodb-linux-x86_64-ubuntu1404-3.2.0/bin/mongos
mongodb-linux-x86_64-ubuntu1404-3.2.0/bin/mongo
[1]+ Done tar -zxvf mongodb-linux-x86_64-ubuntu1404-3.2.0.tgz
[ root@dbversity.com #]
[ root@dbversity.com #]
[ root@dbversity.com #]
[ root@dbversity.com #]ll -lhtr
total 73M
drwxr-xr-x 34 srinivas srinivas 4.0K Dec 28 16:09 ../
-rw-r–r– 1 root root 73M Dec 28 16:24 mongodb-linux-x86_64-ubuntu1404-3.2.0.tgz
drwxr-xr-x 3 root root 4.0K Dec 28 17:22 mongodb-linux-x86_64-ubuntu1404-3.2.0/
drwxr-xr-x 3 root root 4.0K Dec 28 17:22 ./
[ root@dbversity.com #]
[ root@dbversity.com #]
[ root@dbversity.com #]cd mongodb-linux-x86_64-ubuntu1404-3.2.0
[ root@dbversity.com #]
[ root@dbversity.com #]pwd
/home/srinivas/mongodb-3.2/mongodb-linux-x86_64-ubuntu1404-3.2.0
[ root@dbversity.com #]
[ root@dbversity.com #]ll -lhtr
total 108K
-rw-rw-r– 1 srinivas srinivas 36K Dec 5 02:12 THIRD-PARTY-NOTICES
-rw-rw-r– 1 srinivas srinivas 1.4K Dec 5 02:12 README
-rw-rw-r– 1 srinivas srinivas 17K Dec 5 02:12 MPL-2
-rw-rw-r– 1 srinivas srinivas 34K Dec 5 02:12 GNU-AGPL-3.0
drwxr-xr-x 3 root root 4.0K Dec 28 17:22 ../
drwxr-xr-x 3 root root 4.0K Dec 28 17:22 ./
drwxr-xr-x 2 root root 4.0K Dec 28 17:22 bin/
[ root@dbversity.com #]
[ root@dbversity.com #]
[ root@dbversity.com #]cd bin/
[ root@dbversity.com #]
[ root@dbversity.com #]pwd
/home/srinivas/mongodb-3.2/mongodb-linux-x86_64-ubuntu1404-3.2.0/bin
[ root@dbversity.com #]
[ root@dbversity.com #]ll -lhtr
total 236M
-rwxrwxr-x 1 srinivas srinivas 9.6M Dec 5 02:12 bsondump*
-rwxrwxr-x 1 srinivas srinivas 9.9M Dec 5 02:12 mongostat*
-rwxrwxr-x 1 srinivas srinivas 9.9M Dec 5 02:13 mongofiles*
-rwxrwxr-x 1 srinivas srinivas 10M Dec 5 02:13 mongoexport*
-rwxrwxr-x 1 srinivas srinivas 11M Dec 5 02:13 mongoimport*
-rwxrwxr-x 1 srinivas srinivas 17M Dec 5 02:13 mongorestore*
-rwxrwxr-x 1 srinivas srinivas 14M Dec 5 02:13 mongodump*
-rwxrwxr-x 1 srinivas srinivas 9.8M Dec 5 02:13 mongotop*
-rwxrwxr-x 1 srinivas srinivas 9.7M Dec 5 02:13 mongooplog*
-rwxrwxr-x 1 srinivas srinivas 19M Dec 5 02:25 mongo*
-rwxrwxr-x 1 srinivas srinivas 16M Dec 5 02:25 mongos*
-rwxrwxr-x 1 srinivas srinivas 34M Dec 5 02:26 mongoperf*
-rwxrwxr-x 1 srinivas srinivas 35M Dec 5 02:26 mongod*
-rwxrwxr-x 1 srinivas srinivas 34M Dec 5 02:26 mongosniff*
drwxr-xr-x 3 root root 4.0K Dec 28 17:22 ../
drwxr-xr-x 2 root root 4.0K Dec 28 17:22 ./
[ root@dbversity.com #]
[ root@dbversity.com #]
4) Add the location of the binaries is in the PATH variable or bashrc profile as below
[ root@dbversity.com #]export PATH=/home/srinivas/mongodb-3.2/mongodb-linux-x86_64-ubuntu1404-3.2.0/bin:$PATH
To add it permently
[ root@dbversity.com #]echo “export PATH=/home/srinivas/mongodb-3.2/mongodb-linux-x86_64-ubuntu1404-3.2.0/bin:$PATH” >> ~/.bashrc
[ root@dbversity.com #]source ~/.bashrc
[ root@dbversity.com #]
[ root@dbversity.com #]grep “PATH” ~/.bashrc
export PATH=/home/srinivas/mongodb-3.2/mongodb-linux-x86_64-ubuntu1404-3.2.0/bin:/home/srinivas/mongodb-3.2/mongodb-linux-x86_64-ubuntu1404-3.2.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
[ root@dbversity.com #]
[ root@dbversity.com #]
[ root@dbversity.com #]
Now type mongo from any where you should see below errors ( Pls note we’re at to start mongod service)
[ root@dbversity.com #]mongo
MongoDB shell version: 3.2.0
connecting to: test
2015-12-28T18:25:41.254+0530 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2015-12-28T18:25:41.255+0530 E QUERY [thread1] Error: couldn’t connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:224:14
@(connect):1:6
exception: connect failed
[ root@dbversity.com #]
[ root@dbversity.com #]
[ root@dbversity.com #]
[ root@dbversity.com #]
Now start the mongod service as below.
[ root@dbversity.com #]pwd
/home/srinivas/mongodb-3.2
[ root@dbversity.com #]
[ root@dbversity.com #]
[ root@dbversity.com #]
[ root@dbversity.com #]mkdir data
[ root@dbversity.com #]
[ root@dbversity.com #]mongod –dbpath /home/srinivas/mongodb-3.2/data/ –logpath /home/srinivas/mongodb-3.2/mongod.log –smallfiles –nojournal &
[1] 6987
[ root@dbversity.com #]
[ root@dbversity.com #]
[ root@dbversity.com #]
[ root@dbversity.com #]ps -ef | grep mongo
root 6987 3396 1 18:30 pts/0 00:00:00 mongod –dbpath /home/srinivas/mongodb-3.2/data/ –logpath /home/srinivas/mongodb-3.2/mongod.log –smallfiles –nojournal
[ root@dbversity.com #]
[ root@dbversity.com #]
[ root@dbversity.com #]mongo
MongoDB shell version: 3.2.0
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type “help”.
For more comprehensive documentation, see
http://docs.mongodb.org/
Questions? Try the support group
http://groups.google.com/group/mongodb-user
Server has startup warnings:
2015-12-28T18:30:37.635+0530 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2015-12-28T18:30:37.635+0530 I CONTROL [initandlisten]
2015-12-28T18:30:37.635+0530 I CONTROL [initandlisten]
2015-12-28T18:30:37.636+0530 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is ‘always’.
2015-12-28T18:30:37.636+0530 I CONTROL [initandlisten] ** We suggest setting it to ‘never’
2015-12-28T18:30:37.636+0530 I CONTROL [initandlisten]
2015-12-28T18:30:37.636+0530 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is ‘always’.
2015-12-28T18:30:37.636+0530 I CONTROL [initandlisten] ** We suggest setting it to ‘never’
2015-12-28T18:30:37.636+0530 I CONTROL [initandlisten]
>
>
> show dbs
local 0.000GB
>
> use local
switched to db local
>
> show collections
startup_log
>
>
> db.startup_log.find()
{ “_id” : “srinivas-HP-G62-Notebook-PC-1451307637636”, “hostname” : “srinivas-HP-G62-Notebook-PC”, “startTime” : ISODate(“2015-12-28T13:00:37Z”), “startTimeLocal” : “Mon Dec 28 18:30:37.636”, “cmdLine” : { “storage” : { “dbPath” : “/home/srinivas/mongodb-3.2/data/”, “journal” : { “enabled” : false }, “mmapv1” : { “smallFiles” : true } }, “systemLog” : { “destination” : “file”, “path” : “/home/srinivas/mongodb-3.2/mongod.log” } }, “pid” : NumberLong(6987), “buildinfo” : { “version” : “3.2.0”, “gitVersion” : “45d947729a0315accb6d4f15a6b06be6d9c19fe7”, “modules” : [ ], “allocator” : “tcmalloc”, “javascriptEngine” : “mozjs”, “sysInfo” : “deprecated”, “versionArray” : [ 3, 2, 0, 0 ], “openssl” : { “running” : “OpenSSL 1.0.1f 6 Jan 2014”, “compiled” : “OpenSSL 1.0.1f 6 Jan 2014” }, “buildEnvironment” : { “distmod” : “ubuntu1404”, “distarch” : “x86_64”, “cc” : “/opt/mongodbtoolchain/bin/gcc: gcc (GCC) 4.8.2”, “ccflags” : “-fno-omit-frame-pointer -fPIC -fno-strict-aliasing -ggdb -pthread -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch -Werror -O2 -Wno-unused-local-typedefs -Wno-unused-function -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-missing-braces -fno-builtin-memcmp”, “cxx” : “/opt/mongodbtoolchain/bin/g++: g++ (GCC) 4.8.2”, “cxxflags” : “-Wnon-virtual-dtor -Woverloaded-virtual -std=c++11”, “linkflags” : “-fPIC -pthread -Wl,-z,now -rdynamic -fuse-ld=gold”, “target_arch” : “x86_64”, “target_os” : “linux” }, “bits” : 64, “debug” : false, “maxBsonObjectSize” : 16777216, “storageEngines” : [ “devnull”, “ephemeralForTest”, “mmapv1”, “wiredTiger” ] } }
>
>