MongoDB
Installation on Linux OS
MongoDb Installation on Ubuntu 12.04 - 2.6 version with text search
# apt-get update
# apt-get install mongodb-org
This installs 4 packages: mongodb-org-mongos, mongodb-org-server, mongodb-org-shell and mongodb-org-tools
# mongo --version
MongoDB shell version: 2.6.10
MongoDB Installation on CentOS 6.5
#yum remove mongodb-server-2.4.13-1.el6.x86_64 -if previos version exists, remove it
#vim /etc/yum.repos.d/mongodb.repo - create repo for 64-bit system
[mongodb]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
enabled=1
# yum install mongodb-org
# mongo --version
MongoDB shell version: 2.6.10
Controlling Mongo - Ubuntu
1. Check MongoDB process
#ps aux | grep mongo
mongodb 4704 0.2 2.2 156200 45584 ? Ssl 17:54 0:00 /usr/bin/mongod --config /etc/mongodb.conf
runs on process 4704 with configuration in /etc/mongodb.conf
2.service commands - works on Centos 6.5
#service mongodb status
mongodb start/running, process 4704
#service mongod stop
#service mongod start
#service mongod restart
Sometimes on error lock file is generated. Delete /var/lib/mongodb/mongod.lock
3. Get the version
#mongo -version
MongoDB shell version: 2.4.12
4. Check if the MongoDB will start on boot
#chkconfig --list mongodb
mongodb 0:off 1:off 2:off 3:off 4:off 5:off 6:off
5. Check Mongo port
#netstat -an | grep mongo
unix 2 [ ACC ] STREAM LISTENING 8994 /tmp/mongodb-27017.sock
#lsof -iTCP -sTCP:LISTEN | grep mongo
mongod 1004 mongodb 7u IPv4 8993 0t0 TCP *:27017 (LISTEN)
mongod 1004 mongodb 9u IPv4 8995 0t0 TCP *:28017 (LISTEN)
6. run in browser http://localhost:28017/
Controlling Mongo - Ubuntu 12.04
1. start mongod server
#mongod --config /etc/mongod.conf
#mongod --fork - starting process in background
2. stop mongod server
#mongod --shutdown --config /etc/mongod.conf
or
# mongo
> use admin
> db.shutdownServer()
Config file /etc/mongod.conf for Ubuntu 12.04
# mongod.conf - Mongo 2.6
#where to log
logpath=/var/log/mongodb/mongod.log
logappend=true
# fork and run in background
fork=true
#port=27017
dbpath=/var/lib/mongodb
# location of pidfile
pidfilepath=/run/mongod.pid
# Listen to local interface only. Comment out to listen on all interfaces.
bind_ip=0.0.0.0
# Disables write-ahead journaling
# nojournal=true
# Enables periodic logging of CPU utilization and I/O wait
#cpu=true
# Turn on/off security. Off is currently the default
#noauth=true
#auth=true
# Verbose logging output.
#verbose=true
# Inspect all client data for validity on receipt (useful for
# developing drivers)
#objcheck=true
# Enable db quota management
#quota=true
# Set oplogging level where n is
# 0=off (default)
# 1=W
# 2=R
# 3=both
# 7=W+some reads
#diaglog=0
# Ignore query hints
#nohints=true
# Enable the HTTP interface (Defaults to port 28017).
#httpinterface=true
# Turns off server-side scripting. This will result in greatly limited
# functionality
#noscripting=true
# Turns off table scans. Any query that would do a table scan fails.
#notablescan=true
# Disable data file preallocation.
#noprealloc=true
# Specify .ns file size for new databases.
# nssize=<size>
# Replication Options
# in replicated mongo databases, specify the replica set name here
#replSet=setname
# maximum size in megabytes for replication operation log
#oplogSize=1024
# path to a key file storing authentication info for connections
# between replica set members
#keyFile=/path/to/keyfile