Total Pageviews

Tuesday 27 October 2015

Install MongoDB on Redhat 6

Compiled versions of MongoDB for Linux provide a simple option for installing MongoDB for other Linux systems without supported packages.

Install for 64-bit Linux

1 . Download the binary files for the desired release of MongoDB.Download the binaries from https://www.mongodb.org/downloads.

2 Extract the files from the downloaded archive.

[oracle@node1 mongoDB]$ tar -zxvf mongodb-linux-x86_64-rhel62-3.0.7
mongodb-linux-x86_64-rhel62-3.0.7/README
mongodb-linux-x86_64-rhel62-3.0.7/THIRD-PARTY-NOTICES
mongodb-linux-x86_64-rhel62-3.0.7/GNU-AGPL-3.0
mongodb-linux-x86_64-rhel62-3.0.7/bin/mongodump
mongodb-linux-x86_64-rhel62-3.0.7/bin/mongorestore
mongodb-linux-x86_64-rhel62-3.0.7/bin/mongoexport
mongodb-linux-x86_64-rhel62-3.0.7/bin/mongoimport
mongodb-linux-x86_64-rhel62-3.0.7/bin/mongostat
mongodb-linux-x86_64-rhel62-3.0.7/bin/mongotop
mongodb-linux-x86_64-rhel62-3.0.7/bin/bsondump
mongodb-linux-x86_64-rhel62-3.0.7/bin/mongofiles
mongodb-linux-x86_64-rhel62-3.0.7/bin/mongooplog
mongodb-linux-x86_64-rhel62-3.0.7/bin/mongoperf
mongodb-linux-x86_64-rhel62-3.0.7/bin/mongod
mongodb-linux-x86_64-rhel62-3.0.7/bin/mongos
mongodb-linux-x86_64-rhel62-3.0.7/bin/mongo


3 Copy the extracted archive to the target directory.
Copy the extracted folder to the location from which MongoDB will run.

mkdir -p  /data01/mongoDB/mongodb/
cp -R -n mongodb-linux-x86_64-rhel62-3.0.7/ /data01/mongoDB/mongodb/


4
Ensure the location of the binaries is in the PATH variable.
The MongoDB binaries are in the bin/ directory of the archive. To ensure that the binaries are in your PATH, you can modify your PATH.

For example, you can add the following line to your shell’s rc file (e.g. ~/.bashrc):

export PATH=<mongodb-install-directory>/bin:$PATH
Replace <mongodb-install-directory> with the path to the extracted MongoDB archive.


export PATH=/data01/mongoDB/mongodb/bin:$PATH


Run MongoDB

1. Create the data directory.

Before you start MongoDB for the first time, create the directory to which the mongod process will write data. By default, the mongod process uses the /data/db directory. If you create a directory other than this one, you must specify that directory in the dbpath option when starting the mongod process later in this procedure.

The following example command creates the data directory . ( Default location is /data/db. )

mkdir -p /data01/mongoDB/db/

2 .Set permissions for the data directory.

Before running mongod for the first time, ensure that the user account running mongod has read and write permissions for the directory.

3 . Run MongoDB.
To run MongoDB, run the mongod process at the system prompt. If necessary, specify the path of the mongod or the data directory. See the following examples.

Run without specifying paths
If your system PATH variable includes the location of the mongod binary and if you use the default data directory (i.e., /data/db), simply enter mongod at the system prompt:

mongod
Specify the path of the mongod . If your PATH does not include the location of the mongod binary, enter the full path to the mongod binary at the system prompt:

<path to binary>/mongod

[oracle@node1 ~]$ which mongod

/data01/mongoDB/mongodb/bin/mongod


Specify the path of the data directory
If you do not use the default data directory (i.e., /data/db), specify the path to the data directory using the --dbpath option:

[oracle@node1 ~]$ mongod --dbpath /data01/mongoDB/db/

mongod: /usr/lib64/libssl.so.10: no version information available (required by mongod)
mongod: /usr/lib64/libcrypto.so.10: no version information available (required by mongod)
mongod: /usr/lib64/libcrypto.so.10: no version information available (required by mongod)
2015-10-27T01:26:59.213-0400 I JOURNAL  [initandlisten] journal dir=/data01/mongoDB/db/journal
2015-10-27T01:26:59.213-0400 I JOURNAL  [initandlisten] recover : no journal files present, no recovery needed
2015-10-27T01:26:59.583-0400 I JOURNAL  [initandlisten] preallocateIsFaster=true 4.26
2015-10-27T01:26:59.854-0400 I JOURNAL  [initandlisten] preallocateIsFaster=true 3
2015-10-27T01:27:01.562-0400 I JOURNAL  [initandlisten] preallocateIsFaster=true 10.6
2015-10-27T01:27:01.562-0400 I JOURNAL  [initandlisten] preallocating a journal file /data01/mongoDB/db/journal/prealloc.0
2015-10-27T01:27:08.844-0400 I -        [initandlisten]   File Preallocator Progress: 471859200/1073741824 43%
2015-10-27T01:27:11.207-0400 I -        [initandlisten]   File Preallocator Progress: 681574400/1073741824 63%
2015-10-27T01:27:14.075-0400 I -        [initandlisten]   File Preallocator Progress: 775946240/1073741824 72%
2015-10-27T01:27:17.134-0400 I -        [initandlisten]   File Preallocator Progress: 859832320/1073741824 80%
2015-10-27T01:27:21.530-0400 I -        [initandlisten]   File Preallocator Progress: 933232640/1073741824 86%
2015-10-27T01:27:26.223-0400 I -        [initandlisten]   File Preallocator Progress: 996147200/1073741824 92%
2015-10-27T01:27:37.468-0400 I JOURNAL  [initandlisten] preallocating a journal file /data01/mongoDB/db/journal/prealloc.1
2015-10-27T01:27:40.330-0400 I -        [initandlisten]   File Preallocator Progress: 471859200/1073741824 43%
2015-10-27T01:27:43.282-0400 I -        [initandlisten]   File Preallocator Progress: 566231040/1073741824 52%
2015-10-27T01:27:47.742-0400 I -        [initandlisten]   File Preallocator Progress: 608174080/1073741824 56%
2015-10-27T01:27:50.298-0400 I -        [initandlisten]   File Preallocator Progress: 744488960/1073741824 69%
2015-10-27T01:27:53.087-0400 I -        [initandlisten]   File Preallocator Progress: 817889280/1073741824 76%
2015-10-27T01:27:56.464-0400 I -        [initandlisten]   File Preallocator Progress: 901775360/1073741824 83%
2015-10-27T01:27:59.441-0400 I -        [initandlisten]   File Preallocator Progress: 964689920/1073741824 89%
2015-10-27T01:28:02.206-0400 I -        [initandlisten]   File Preallocator Progress: 1038090240/1073741824 96%
2015-10-27T01:28:17.693-0400 I JOURNAL  [initandlisten] preallocating a journal file /data01/mongoDB/db/journal/prealloc.2
2015-10-27T01:28:20.164-0400 I -        [initandlisten]   File Preallocator Progress: 492830720/1073741824 45%
2015-10-27T01:28:23.287-0400 I -        [initandlisten]   File Preallocator Progress: 566231040/1073741824 52%
2015-10-27T01:28:26.361-0400 I -        [initandlisten]   File Preallocator Progress: 671088640/1073741824 62%
2015-10-27T01:28:29.421-0400 I -        [initandlisten]   File Preallocator Progress: 765460480/1073741824 71%
2015-10-27T01:28:32.484-0400 I -        [initandlisten]   File Preallocator Progress: 849346560/1073741824 79%
2015-10-27T01:28:35.216-0400 I -        [initandlisten]   File Preallocator Progress: 954204160/1073741824 88%
2015-10-27T01:28:38.353-0400 I -        [initandlisten]   File Preallocator Progress: 1038090240/1073741824 96%
2015-10-27T01:28:54.789-0400 I JOURNAL  [durability] Durability thread started
2015-10-27T01:28:54.789-0400 I JOURNAL  [journal writer] Journal writer thread started
2015-10-27T01:28:54.815-0400 I CONTROL  [initandlisten] MongoDB starting : pid=3131 port=27017 dbpath=/data01/mongoDB/db/ 64-bit host=node1.localdomain
2015-10-27T01:28:54.823-0400 I CONTROL  [initandlisten]
2015-10-27T01:28:54.823-0400 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2015-10-27T01:28:54.823-0400 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2015-10-27T01:28:54.823-0400 I CONTROL  [initandlisten]
2015-10-27T01:28:54.823-0400 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2015-10-27T01:28:54.823-0400 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2015-10-27T01:28:54.823-0400 I CONTROL  [initandlisten]
2015-10-27T01:28:54.823-0400 I CONTROL  [initandlisten] db version v3.0.7
2015-10-27T01:28:54.823-0400 I CONTROL  [initandlisten] git version: 6ce7cbe8c6b899552dadd907604559806aa2e9bd
2015-10-27T01:28:54.823-0400 I CONTROL  [initandlisten] build info: Linux ip-10-101-218-12 2.6.32-220.el6.x86_64 #1 SMP Wed Nov 9 08:03:13 EST 2011 x86_64 BOOST_LIB_VERSION=1_49
2015-10-27T01:28:54.823-0400 I CONTROL  [initandlisten] allocator: tcmalloc
2015-10-27T01:28:54.823-0400 I CONTROL  [initandlisten] options: { storage: { dbPath: "/data01/mongoDB/db/" } }
2015-10-27T01:28:54.922-0400 I INDEX    [initandlisten] allocating new ns file /data01/mongoDB/db/local.ns, filling with zeroes...
2015-10-27T01:28:55.376-0400 I STORAGE  [FileAllocator] allocating new datafile /data01/mongoDB/db/local.0, filling with zeroes...
2015-10-27T01:28:55.376-0400 I STORAGE  [FileAllocator] creating directory /data01/mongoDB/db/_tmp
2015-10-27T01:28:55.554-0400 I STORAGE  [FileAllocator] done allocating datafile /data01/mongoDB/db/local.0, size: 64MB,  took 0.156 secs
2015-10-27T01:28:55.569-0400 I NETWORK  [initandlisten] waiting for connections on port 27017

[oracle@node1 sf_SOFTWARES]$ ps -ef| grep mongo
oracle    3131  2884  2 01:26 pts/0    00:00:03 mongod --dbpath /data01/mongoDB/db/


4 . Begin using MongoDB.

[oracle@node1 bin]$ ./mongo

./mongo: /usr/lib64/libssl.so.10: no version information available (required by ./mongo)
./mongo: /usr/lib64/libcrypto.so.10: no version information available (required by ./mongo)
./mongo: /usr/lib64/libcrypto.so.10: no version information available (required by ./mongo)
MongoDB shell version: 3.0.7
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-10-27T01:28:54.823-0400 I CONTROL  [initandlisten]
2015-10-27T01:28:54.823-0400 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2015-10-27T01:28:54.823-0400 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2015-10-27T01:28:54.823-0400 I CONTROL  [initandlisten]
2015-10-27T01:28:54.823-0400 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2015-10-27T01:28:54.823-0400 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2015-10-27T01:28:54.823-0400 I CONTROL  [initandlisten]
>
> db
test

No comments:

Post a Comment