Install MongoDB 2.0.4 on RHEL CentOS Fedora Ubuntu & Debian
This howto guide shows how to install MongoDB 2.0.4 on RHEL 6.2/6.1/6/5.8, CentOS 6.2/6.1/6/5.8, Fedora 16/15/14/13/12, Ubuntu 12.04/11.10/11.04/10.10/10.04 and Debian using MongoDB own YUM repositories for RHEL, CentOS and Fedora and apt-get for Ubuntu and Debian.
For all 32-bit RPM-based distros with yum, put this at /etc/yum.repos.d/10gen.repo:
For Ubunut, put these below lines to “/etc/apt/sources.list”:
What is MongoDB?
MongoDB (from "humongous") is an open source scalable, high-performance and schema-free document-oriented NoSQL database system written in C++. MongoDB bridges the gap between key-value stores (which are fast and highly scalable) and traditional RDBMS systems (which provide structured schemas and powerful queries).MongoDB Features
- Document-oriented storage (the simplicity and power of JSON-like data schemas)
- Dynamic queries
- Full index support, extending to inner-objects and embedded arrays
- Query profiling
- Fast, in-place updates
- Efficient storage of binary data large objects (e.g. photos and videos)
- Replication and fail-over support
- Auto-sharding for cloud-level scalability
- MapReduce for complex aggregation
- Commercial Support, Training, and Consulting
Why MongoDB?
- Document-oriented
- Documents (objects) map nicely to programming language data types
- Embedded documents and arrays reduce need for joins
- Dynamically-typed (schemaless) for easy schema evolution
- No joins and no multi-document transactions for high performance and easy scalability
- High performance
- No joins and embedding makes reads and writes fast
- Indexes including indexing of keys from embedded documents and arrays
- Optional streaming writes (no acknowledgements)
- High availability
- Replicated servers with automatic master failover
- Easy scalability
- Automatic sharding (auto-partitioning of data across servers)
- Reads and writes are distributed over shards
- No joins or multi-document transactions make distributed queries easy and fast
- Eventually-consistent reads can be distributed over replicated servers
- Automatic sharding (auto-partitioning of data across servers)
- Rich query language
Install MongoDB 2.0.4 on RHEL 6.2/6.1/6/5.8, CentOS 6.2/6.1/6/5.8, Fedora 16-12, Ubuntu 12.04/11.10/11.04/10.10/10.04 and Debian
How to Install MongoDB 2.0.4 RHEL, CentOS and Fedora
Step 1: Adding 10gen MongoDB Repository
Add 10gen Mongodb-repo (yum-installable RPM packages) on RHEL 6.2/6.1/6/5.8, CentOS 6.2/6.1/6/5.8, Fedora 16-12 for x86 and x86_64 platforms.For all 32-bit RPM-based distros with yum, put this at /etc/yum.repos.d/10gen.repo:
[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/
redhat/os/i686For all 64-bit RPM-based distros with yum, put this at /etc/yum.repos.d/10gen.repo:
gpgcheck=0
[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/
redhat/os/x86_64
gpgcheck=0
Step 2: Installing MongoDB 2.0.4
Installing MongoDB Database Server on RHEL 6.2/6.1/6/5.8, CentOS 6.2/6.1/6/5.8, Fedora 16-12 for x86 and x86_64 platforms using YUM.yum install mongo-10gen mongo-10gen-serverNote: for users upgrading from older (pre-2/2011) packaging scheme, it may be necessary to uninstall your existing "mongo-stable", "mongo-stable-server", "mongo-unstable", "mongo-unstable-server" packages before installing the latest mongo-10gen, mongo-10gen-server pacakges.
Step 3: Configure MongoDB Database Server
Open and edit /etc/mongod.conf file with VI Editor. Verify and set basic settings, before starting MongoDB Database Server.vi /etc/mongod.conf
logpath=/var/log/mongo/mongod.log
port=27017
dbpath=/var/lib/mongo
Step 4: Starting MongoDB Database Server
/etc/init.d/mongod start
## OR ##
service mongod start
Step 5: Testing MongoDB Database Server
Testing with MongoDB command line client.mongo
Step 6: Executing MongoDB Basic Commands
> show dbs
> show collections
> show users
> use <db name>
Step 7: Starting & Stopping MongoDB
Here is a quick reference to the commands that control the execution of the mongod server process:service mongodb status
service mongodb stop
service mongodb start
service mongodb restart
## OR ##
/etc/init.d/mongod status
/etc/init.d/mongod stop
/etc/init.d/mongod start
/etc/init.d/mongod restart
Step 8: Opening MongoDB Port on Firewall
Open file /etc/sysconfig/iptables and add the following line at the bottom and restart iptables.-A INPUT -m state --state NEW -m tcp -p tcp --dport 27017
-j ACCEPT
/etc/init.d/iptables restart
## OR ##
service iptables restart
Step 9: Testing MongoDB Remote Connection
mongo serverip:port/databasename
## Example ##
mongo 192.168.1.21:27017/ravisaive
How to Install MongoDB 2.0.4 on Ubuntu and Debian
Step 1: Adding 10gen MongoDB source.list
The 10gen package contains the latest mongoDB version, add below lines at the bottom of the file “/etc/apt/sources.list” on Ubuntu 12.04/11.10/11.04/10.10/10.04 and Debian.For Ubunut, put these below lines to “/etc/apt/sources.list”:
deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart
dist 10genFor Debian, put these below lines to “/etc/apt/sources.list”:
deb http://downloads-distro.mongodb.org/repo/debian-sysvinit
dist 10gen
step 2: Adding GPG Key
10gen package required GPG key, import it:sudo apt-key adv --keyserver keyserver.ubuntu.com --recv
7F0CEB10
step 3: Insalling MongoDB
sudo apt-get update
sudo apt-get install mongodb-10gen
step 4: Starting MongoDB
sudo status mongodb
sudo stop mongodb
sudo start mongodb
sudo restart mongodb
step 5: Testing MongoDB
To verify it, just connect it with “mongo”mongoIn case you're facing any difficulties while setting up MongoDB Database Server, please share with us via comment.
No comments:
Post a Comment