Installing MongoDB on CentOS 6

The first step is to configure the repositories. Create the following file /etc/yum.repos.d/10gen.repo with the following contents:

For 32-bit systems:

[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/i686
gpgcheck=0
enabled=1

For 64-bit systems:

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

Install Mongo

yum install mongo-10gen mongo-10gen-server

 

Configure MongoDB

You can configure Mongo by editing the following file:

/etc/mongod.conf

Set Mongo to autostart on system boot:

chkconfig mongod on

Start Mongo

service mongod start

Stop Mongo

service mongod stop

Restart Mongo

service mongod restart

 

Testing

The package includes the mongo console. This tool is a console interface similar to mysql.

mongo

Type a couple commands to test it:

db.test.save( { a: 1 } )
db.test.find()

What to check if you cannot connect:

 

3 Replies to “Installing MongoDB on CentOS 6”

Leave a Reply