Download MongoDB's compression package from the official website. Http://www.mongodb.org/downloads
Unzip the Mongodb-linux-x86_64-2.6.8.tgz
[Email protected] downloads]$ tar zxvf mongodb-linux-x86_64-2.6.8.tgz mongodb-linux-x86_64-2.6.8/ Readmemongodb-linux-x86_64-2.6.8/third-party-noticesmongodb-linux-x86_64-2.6.8/gnu-agpl-3.0mongodb-linux-x86_ 64-2.6.8/bin/mongodumpmongodb-linux-x86_64-2.6.8/bin/mongorestoremongodb-linux-x86_64-2.6.8/bin/ Mongoexportmongodb-linux-x86_64-2.6.8/bin/mongoimportmongodb-linux-x86_64-2.6.8/bin/mongostatmongodb-linux-x86 _64-2.6.8/bin/mongotopmongodb-linux-x86_64-2.6.8/bin/mongooplogmongodb-linux-x86_64-2.6.8/bin/ Mongofilesmongodb-linux-x86_64-2.6.8/bin/bsondumpmongodb-linux-x86_64-2.6.8/bin/mongoperfmongodb-linux-x86_ 64-2.6.8/bin/mongodmongodb-linux-x86_64-2.6.8/bin/mongosmongodb-linux-x86_64-2.6.8/bin/mongo
MongoDB does not need to be installed to apply, so we deploy it ourselves to/usr/local/
First create a new MongoDB folder under the usr/local/directory (note to SU permissions)
[[Email protected]/]$ CD/[[email protected]/]$ CD Usr/local/[[email protected] local]$ Lsbin etc games include Lib lib64 libexec sbin share src
[[email protected] local]$ sudo mkdir mongodb[sudo] password for Neil: [[email protected] local]$ Lsbin etc Games inclu De Lib lib64 libexec mongodb sbin share src
After that, move the previously unzipped Monggodb folder to/Usr/local/mongodb:
[[Email protected] local]$ CD ~/downloads/[[email protected] local]$ sudo mv mongodb-linux-x86_64-2.6.8/*/usr/local/ mongodb/
(or
You can also use the following command in the mongodb-linux-x86_64-2.6.8 folder:
Rsync-a Bin/usr/local/mongodb
)
Then create the location of the database for MongoDB (by default, under/data/db), where the corresponding directory is set up under MongoDB data/
[Neil@neilhost mongodb]$ sudo mkdir data
Create a log file for MongoDB dblogs
[[email protected] mongodb]$ sudo touch dblogs
[Email protected] mongodb]$ lsbin data dblogs gnu-agpl-3.0 README third-party-notices
At this point, MongoDB is even installed.
——————————————————————————————
Bin can see the 13 binary files used by mongdb
[Email protected] mongodb]$ tree Binbin├──bsondump├──mongo├──mongod├──mongodump├──mongoexport├──mongofiles├──mong Oimport├──mongooplog├──mongoperf├──mongorestore├──mongos├──mongostat└──mongotop0 directories, files
The previous version of MongoDB's bin had only 12 binaries, and some binary files were also different from the present one.
————————————————————————————————————————————
If you need to start MongoDB automatically every time the server is powered on, you need to set some environment variables
Adding a MongoDB boot project to rc.local ensures that MongoDB starts when the server is powered on:
echo "/usr/local/mongodb/bin/mongodb"--dbpath=/usr/local/mongodb/data ">>/etc/rc/local
However, I still like to start it myself. or write your own in a script, and then start what you want to configure yourself.
The manual Start method is as follows:
[[Email protected] mongodb]$ CD Bin[[email protected] bin]$ lsbsondump mongodump mongoimport mongorestore MONGOTOPMO NGO Mongoexport mongooplog mongosmongod mongofiles mongoperf mongostat[[email protected] bin]$ sudo./mongo D--dbpath=/usr/local/mongodb/data/--logpath=/usr/local/mongodb/dblogs--fork[sudo] password for neil:about to fork Child process, waiting until server was ready for connections.forked process:6593
Here--dbpath specifies the path to the database file store,--logpath specifies what the log file path is, and the previous dblogs can be named as a different name, as specified here.
The--fork parameter refers to the execution in the background, and of course the & symbol.
The system returns the forked process:6593 refers to the process number that the system assigns to MongoDB PID is 6593 (each time is different OH)
So now MongoDB has been successfully launched it?
by command:
[[email protected] bin]$ pstree -p| grep mongod |-mongod (6593)-+-{mongod} (6594) | | -{mongod} (6595) | |-{mongod} (6596) | |-{mongod} (6608) | |-{mongod} (6609) | |-{mongOD} (6610) | |-{mongod} (6611) | |-{mongod} (6612) | '-{mongod} (6613)
There are 9 sub-processes under main process 6593.
The above manually initiated statements can be placed in the/etc/rc.local file, allowing the system to automatically execute after booting. (/etc/rc.local is the last script executed after Linux boot )
——————————————————————————————————
How do I turn off MongoDB services?
[[email protected] bin]$ sudo pkill mongod[sudo] password for Neil: [[email protected] bin]$ pstree-p| grep mongod[[email protected] bin]$
In this way, the MONGDB is closed with the Pkill command. You can also use kill--all here.
Note: But you can not use kill-9 to close MongoDB, otherwise you will find the next time can not successfully start Mongod!!! Remember!!!
_____________________________________________
Here is another way to add:
Write a shell script file mongodbstart.sh, the file contents are as follows:
Sudo/usr/local/mongodb/bin/mongod--dbpath=/usr/local/mongodb/data/--logpath=/usr/local/mongodb/dblogs--fork
Then execute the shell script:
[[email protected] downloads]$ sh mongodbstart.shabout to fork child Process, waiting until server is ready for connections.forked process: 7042child process started successfully, parent exiting[[email protected] Downloads]$ pstree -p| grep mongod |-mongod (7042)-+-{mongod} (7043) | |-{mongod} (7044) | |-{mongod} (7045) | |-{ Mongod} (7046)   &NBsp; | |-{mongod} (7047) | |-{mongod} (7048) | |-{mongod} (7049) | |-{ Mongod} (7050) | '-{mongod} (7051)
Later, if there are other things that need to be started together, they can all be added to the script file and started together. And will not start at boot time.
MongoDB Starter Series (2)--installing, booting, shutting down MongoDB under Linux and Considerations (verbose)