Friday, November 18, 2016

MongoDB

MongoDB is growing in popularity, open-source database. It stores data as documents and format is BSON,JSON.

1.  Installation

Create /etc/yum.repos.d/mongodb-org-3.0.repo 

[root@db02 ~]# cat /etc/yum.repos.d/mongodb-org-3.0.repo 
[mongodb-org-3.2]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/x86_64/
gpgcheck=0
enabled=1
#gpgkey=https://www.mongodb.org/static/pgp/server-3.2.asc

#For Old verion

#[mongodb-org-2.6]
#name=MongoDB 2.6 Repository
#baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
#gpgcheck=0
#enabled=1


[root@db02 ~]# yum clean all

Latest stable release
[root@db02 ~]# yum install -y mongodb-org

For a specific release: version 3.0.3
[root@db02 ~]# yum install -y mongodb-org-3.0.3 mongodb-org-server-3.0.3 mongodb-org-shell-3.0.3 mongodb-org-mongos-3.0.3 mongodb-org-tools-3.0.3

Version 3.2.9
[root@db02 ~]# yum install -y mongodb-org-3.2.9 mongodb-org-server-3.2.9 mongodb-org-shell-3.2.9 mongodb-org-mongos-3.2.9 mongodb-org-tools-3.2.9

Version 3.2.10
[root@db02 ~]# yum install -y mongodb-org-3.2.10 mongodb-org-server-3.2.10 mongodb-org-shell-3.2.10 mongodb-org-mongos-3.2.10 mongodb-org-tools-3.2.10

If you have older version of openssl than version: 1.0.1e, you can get issues after installajon/upgrading MongoDB 3.x  

Config File:

[root@db02 ~]# cat /etc/mongod.conf
# This is a mongo.conf file
dbpath=/db/mongo
logpath=/var/log/mongo/mongod.log
logappend=true
quiet = true
fork = true
port = 27017
replSet = rs0
oplogSize = 1000

Start/Stop MongoDB

[root@db02 ~]# /etc/init.d/mongod start

[root@db02 ~]# /etc/init.d/mongod stop

Other options
Usage: /etc/init.d/mongod {start|stop|status|restart|reload|force-reload|condrestart}

If you get some complaints about process limits (observered in version 3.2.9) when starting, create a file and add the nproc value manually in following file. 

[root@db02 ~]# cat /etc/security/limits.d/99-mongodb-nproc.conf
mongod     soft      nproc        64000

AUTO START:

It is observed that version 3.2.x has issue better to check and fix autostart 

[root@db02 ~]# chkconfig --list |grep mongod
mongod          0:off   1:off   2:off    3:off    4:off    5:off    6:off
[root@db02 ~]# chkconfig mongod on 

[root@ios-nod-qa-db02 ~]# chkconfig --list| grep mongod
mongod          0:off   1:off   2:on    3:on    4:on    5:on    6:off


No comments: