The distributed document storage database MongoDB is so popular now. However, at the time of the test, version 1.8.1 was now available in version 2.4, but NoSQL was developing too fast.
The distributed document storage database MongoDB is so popular now. However, at the time of the test, version 1.8.1 was now available in version 2.4, but NoSQL was developing too fast.
The distributed document storage database MongoDB is so popular now. In response to the requirements of cloud computing last year, I tried it a little.
However, at the time of the test, version 1.8.1 was now available in version 2.4, but NoSQL was developing too fast.
Mongodb provides two download editions: mongodb-linux-x86_64-1.8.1.tgz and mongodb-linux-x86_64-static-legacy-1.8.1.tgz
Difference: "legacy static" is used only when mongodb cannot be started in an old linux system or a floating point exception occurs,
Try to use mongodb-linux-x86_64-1.8.1.tgz
-- ===================================================== ========================================================== ======================================
-- Add users and groups
Groupadd mongodb
Useradd-g mongodb
[Root @ localhost ~] # Mkdir-p/data/db/m_data
[Root @ localhost ~] # Chown-R mongodb: mongodb/data/db *
Tar zxvf mon *. tgz
-- Tar zxf mongodb-linux-x86_64-static-legacy-1.8.1.tgz-C/usr/local/mongodb
-- ===================================================== ========================================================== ======================================
/Data/mongodbexe/bin
-- Start
/Data/mongodbexe/bin/mongod -- dbpath/data/db -- logpath/data/db/log/xclmongo. log -- fork
-- Enter shell
/Data/mongodbexe/bin/mongo
-- ===================================================== ========================================================== ======================================
-- ===================================================== ========================================================== ======================================
-- Install the corresponding service
Vi/etc/rc. local
/Data/mongodbexe/bin/mongod -- dbpath/data/db -- logpath/data/db/log/xclmongo. log -- logappend -- fork run
-- Port 27017
/Data/mongodbexe/bin/mongod -- dbpath/data/db -- fork -- logpath/data/db/log/xclmongo. log -- logappend run
-- ===================================================== ========================================================== ======================================
/Data/mongodbexe/bin/mongod -- dbpath/data/db -- fork -- logpath/data/db/log/xclmongo. log -- logappend run
-- ===================================================== ========================================================== ======================================
Using MongoDB
Among the tools attached ded in the mongo-10gen package, is the mongo shell. You can connect to your MongoDB instance by issuing the following command at the system prompt:
Mongo
This will connect to the database running on the localhost interface by default. at the mongo prompt, issue the following two commands to insert a record in the "test" collection of the (default) "test" database and then retrieve that document.
> Db. test. save ({a: 1 })
> Db. test. find ()
-- ===================================================== ========================================================== ======================================
-- Command Method
> Use admin
Switched to db admin
> Db. shutdownServer ()
Process Method
Ps-aef | grep mongod
Kill-2
-- Disable
Kill-15 pid
-- Or:
[Root @ localhost ~] #/Data/mongodbexe/bin/mongo
MongoDB shell version: 2.0.7
Connecting to: test
> Shutdown
Tue Aug 21 13:43:38 ReferenceError: shutdown is not defined (shell): 1
> Use admin;
Switched to db admin
> Db. shutdownServer ();
Tue Aug 21 13:44:02 DBClientCursor: init call () failed
Tue Aug 21 13:44:03 query failed: admin. $ cmd {shutdown: 1.0} to: 127.0.0.1
Server shocould be down...
Tue Aug 21 13:44:03 trying reconnect to 127.0.0.1
Tue Aug 21 13:44:03 reconnect 127.0.0.1 failed couldn't connect to server 127.0.0.1
Tue Aug 21 13:44:03 Error: error doing query: unknown shell/collection. js: 151
>
--'
-- ===================================================== ========================================================== ======================================
[Root @ localhost bin] #/data/mongodbexe/bin/mongod -- dbpath/data/db -- fork -- logpath/data/db/log/xclmongo. log -- logappend
All output going to:/data/db/log/xclmongo. log
Forked process: 20946
[Root @ localhost bin] #./mongo
MongoDB shell version: 2.0.7
Connecting to: test
Tue Aug 21 13:33:24 Error: couldn't connect to server 127.0.0.1 shell/mongo. js: 84 --'
Exception: connect failed
-- ===================================================== ========================================================== ======================================
For more details, please continue to read the highlights on the next page:
MongoDB details: click here
MongoDB: click here
Related reading:
MongoDB backup and recovery
CentOS compilation and installation of MongoDB
CentOS compilation and installation of php extensions for MongoDB and mongoDB
CentOS 6 install MongoDB and server configuration using yum
Install MongoDB2.4.3 in Ubuntu 13.04
How to create a new database and set in MongoDB
MongoDB beginners must read (both concepts and practices)
MongoDB authoritative Guide (The Definitive Guide) in English [PDF]