Step #1: Add the MongoDB Repository
vi /etc/yum.repos.d/mongodb.repo
[mongodb]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
enabled=1
Then exit and save the file with the command :wq
Step #2: Install MongoDB
yum install mongo-10gen mongo-10gen-server
Dependencies Resolved
=======================================================================
Package Arch Version Repository Size
=======================================================================
Installing:
mongodb-org x86_64 2.6.5-1 mongodb 4.6 k
mongodb-org-server x86_64 2.6.5-1 mongodb 9.0 M
Installing for dependencies:
mongodb-org-mongos x86_64 2.6.5-1 mongodb 6.8 M
mongodb-org-shell x86_64 2.6.5-1 mongodb 4.3 M
mongodb-org-tools x86_64 2.6.5-1 mongodb 89 M
Transaction Summary
=======================================================================
Install 5 Package(s)
Total download size: 109 M
Installed size: 276 M
Is this ok [y/N]: y
MongoDb configuration file path:
/etc/mongod.conf
Step #3: Get MongoDB Running
service mongod start
Check MongoDB Service Status
service mongod status
Summary List of Status Statistics
mongostat
Enter the MongoDB Command Line
mongo
By default, running this command will look for a MongoDB server listening on port 27017 on the localhost
interface.
If you’d like to connect to a MongoDB server running on a different port, then use the –port option. For example,
if you wanted to connect to a local MongoDB server listening on port 22222, then you’d issue the following
command:
mongo --port 22222
To Shutdown MongoDB:
service mongod stop
MondoDB Usage:
>mongo
Select a Database
>db
list of databases:
>show dbs
create a new database with name mydb:
>use mydb
confirm the db is created:
>db
Your created database (mydb) is not present in list. To display database you need to insert atleast one document into it.
> db.movie.insert({"name":"linux space station"})
> show dbs
To delete database:
>use test
>db.dropDatabase()
This will delete the selected database. If you have not selected any database, then it will delete default 'test'
database
>show dbs
vi /etc/yum.repos.d/mongodb.repo
[mongodb]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
enabled=1
Then exit and save the file with the command :wq
Step #2: Install MongoDB
yum install mongo-10gen mongo-10gen-server
Dependencies Resolved
=======================================================================
Package Arch Version Repository Size
=======================================================================
Installing:
mongodb-org x86_64 2.6.5-1 mongodb 4.6 k
mongodb-org-server x86_64 2.6.5-1 mongodb 9.0 M
Installing for dependencies:
mongodb-org-mongos x86_64 2.6.5-1 mongodb 6.8 M
mongodb-org-shell x86_64 2.6.5-1 mongodb 4.3 M
mongodb-org-tools x86_64 2.6.5-1 mongodb 89 M
Transaction Summary
=======================================================================
Install 5 Package(s)
Total download size: 109 M
Installed size: 276 M
Is this ok [y/N]: y
MongoDb configuration file path:
/etc/mongod.conf
Step #3: Get MongoDB Running
service mongod start
Check MongoDB Service Status
service mongod status
Summary List of Status Statistics
mongostat
Enter the MongoDB Command Line
mongo
By default, running this command will look for a MongoDB server listening on port 27017 on the localhost
interface.
If you’d like to connect to a MongoDB server running on a different port, then use the –port option. For example,
if you wanted to connect to a local MongoDB server listening on port 22222, then you’d issue the following
command:
mongo --port 22222
To Shutdown MongoDB:
service mongod stop
MondoDB Usage:
>mongo
Select a Database
>db
list of databases:
>show dbs
create a new database with name mydb:
>use mydb
confirm the db is created:
>db
Your created database (mydb) is not present in list. To display database you need to insert atleast one document into it.
> db.movie.insert({"name":"linux space station"})
> show dbs
To delete database:
>use test
>db.dropDatabase()
This will delete the selected database. If you have not selected any database, then it will delete default 'test'
database
>show dbs
No comments:
Post a Comment