We have to Log into the instance as root user
Now we have to add the 10gen MongoDB repository for yum, by creating the file
sudo vi /etc/yum.repos.d/10gen-mongodb.repo
For 64-bit. Copy the below.
[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64
gpgcheck=0
For 32-bit . Copy the below.
[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/i686
gpgcheck=0
Install MongoDB by running the following command
sudo yum install mongo-10gen mongo-10gen-server
Modify the file /etc/mongod.conf Change the location of DB, logs files, ports as necessary
logpath=/var/log/mongo/mongod.log
port=27017
dbpath=/var/lib/mongo
If you have changed the location of the db or log files, make sure that mongod has write permissions at the new locations. If not assign persmission
sudo chown mongod:mongod /data/mongodb
sudo chown mongod:mongod /data/mongo/mongod.log
The new location can be /data/mongodb for dbpath and /data/log/mongo/mongod.log for logpath. If these directories are created then we have to give the permissions to the specified folders
Start MongoDB server
sudo service mongod start
or
sudo /etc/init.d/mongod start
To start MongoDB on server reboot
sudo chkconfig --levels 235 mongod on
High Performance
MongoDB provides high performance data persistence. In particular,
- Support for embedded data models reduces I/O activity on database system.
- Indexes support faster queries and can include keys from embedded documents and arrays.
High Availability
To provide high availability, MongoDB’s replication facility, called replica sets, provide:
- automatic failover.
- data redundancy.
A replica set is a group of MongoDB servers that maintain the same data set, providing redundancy and increasing data availability.
Automatic Scaling
MongoDB provides horizontal scalability as part of its core functionality.
- Automatic sharding distributes data across a cluster of machines.
- Replica sets can provide eventually-consistent reads for low-latency high throughput deployments.
MongoDB is a relatively new breed of database that has no concept of tables, schemas, SQL, or rows. It doesn’t have transactions, ACID compliance, joins, foreign keys, or many of the other features that tend to cause headaches in the early hours of the morning. In short, MongoDB is a very different database than you’re probably used to, especially if you’ve used a relational database management system (RDBMS) in the past. In fact, you might even be shaking your head in wonder at the lack of so-called “standard” features.