Escolar Documentos
Profissional Documentos
Cultura Documentos
com
Originally published on
LinuxTechLab.com
MongoDB is one of the famous , free & open source document oriented No-SQL
database server. MongoDB uses JSON like document format to store data in database,
rather than using rows & columns, as used in SQL databases like MS-SQL, mysql etc.
When compared with SQL databases or relational databases, MongoDB are far more
faster, provide far better performance, are easy to scale & address several shortcomings
of any relational database available. MongoDB can handle large amounts of structured
or unstructured data or can even support multiple data structures. No-SQL databases,
especially MongoDB are the kind of databases that are required to address the needs of
data being used today, whether you need databases for IOT or online gaming or for big
data, MongoDB will be a right fit.
$ vi /etc/yum.repos.d/mongodb-org-3.4.repo
[mongodb-org-3.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-
org/3.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc
now save the file & exit. If you are performing installation on earlier versions of
RHEL/Centos (mostly version prior to 6.5) than you might want to install earlier versions
of MongoDb, as latest one might not work for you. For earlier versions, just replace 3.4
with earlier version i.e.
$ vi /etc/yum.repos.d/mongodb-org-2.6.repo
[mongodb-org-2.6]
name=MongoDB 2.6 Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
enabled=1
Now that we have our repository ready, we can install MongoDB on our server.
Note : Odd numbered versions of MongoDB are meant for development & should not
be used in production environment.
MongoDB Installation
This will install mongodb on our server. Once installed, we need to start the service &
enable it start after boot,
$ systemctl start mongod
$ systemctl enable mongod
Testing MongoDB
To connect to mongodb after its service has been started, open terminal & type
$ mongo
Once logged in, we can see all the availabe databases by using
$ show dbs
Though this command will create a database but it will not save the database until some
data has been added to it. We will now add a collection named inventory in the
database & to do that command is
$ db.inventory.save ( { inventory : Desktops } )
After the collection has been added , database will be automatically saved & we can
verify it by executing command show dbs. This completes our tutorial, if you have any
suggestion or query, please do tell us using the comment box below.
( Recommended Read : MariaDB administration commands for beginners )
If you think we have helped you or just want to support us, please consider these :-
Connect to us: Facebook | Twitter | Google Plus
LinuxTechLab.com