How to Install MongoDB 3.2 on CentOS 7

[code lang=”shell”]
vim /etc/yum.repos.d/mongodb.repo
[/code]
Paste this to the file and save using :wq
[code lang=”shell”]

[MongoDB]
name=MongoDB Repository
baseurl=http://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/x86_64/
gpgcheck=0
enabled=1
[/code]
Download and install mongodb using yum
[code lang=”shell”]
yum install mongodb-org -y
[/code]
Start mongod and configure auto start while system boot
[code lang=”shell”]
/etc/init.d/mongod restart
chkconfig mongod on
[/code]
Check all the versions
[code lang=”shell”]
[[email protected] ~]# mongo –version
MongoDB shell version: 3.2.3
[[email protected] ~]# mongod –version
db version v3.2.3
git version: b326ba837cf6f49d65c2f85e1b70f6f31ece7937
OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
allocator: tcmalloc
modules: none
build environment:
distmod: rhel70
distarch: x86_64
target_arch: x86_64
[/code]
Test the connection
[code lang=”shell”]
[[email protected] ~]# mongo
MongoDB shell version: 3.2.3
> use test
switched to db test
> db.test.save( { juzhax: 1 } )
WriteResult({ "nInserted" : 1 })
> db.test.find()
{ "_id" : ObjectId("56d4ac48b376b143e4749229"), "juzhax" : 1 }
[/code]

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.