MONGO Boot Instructions

Source: Internet
Author: User
Tags mongodb mongodb client mongodb server

Start MongoDB

Yesterday, according to the official example to do, did not specify any of their own parameters, completely using the MONGO default path and parameters to install, if there is no root, the default path of the database can not be established in the root directory under the/data/db, therefore, I would like to define a directory to store data files, how to do it.

Mongod also has a lot of startup options to run Mongod--help to see all the options .

[Mongodb@localhost bin]$./mongod--help
Sat Oct 15 14:17:11
Sat Oct 14:17:11 * note:when using MongoDB bit, you are limited to about 2 gigabytes of data
Sat Oct 14:17:11 * * http://blog.mongodb.org/post/137788967/32-bit-limitations
Sat OCT 14:17:11 * * with--journal, the limit is lower
Sat Oct 15 14:17:11
Allowed Options:
General Options:
-H [--help] Show this usage information
--version Show version Information
-F [--config] arg configuration file specifying additional options
-V [--verbose] is more verbose (include multiple times for more verbosity e.g.-VVVVV)
--quiet quieter output
--port Arg Specify port number
--BIND_IP Arg comma separated list of IP addresses to listen On-all local IPs by default

--dbpath arg directory for datafiles

--maxconns arg max number of simultaneous connections

--logpath arg log file to send write to instead of the Stdout-has to being a file, not directory

among them, startup options can be written directly behind the Mongod, or you can specify a configuration file to load various startup items with a file, such as , such as the file store path for the specified MongoDB, . The default connection port for the/mongod--dbpath=/home/mongodb/data/db MongoDB server is 27017 c11> can also specify port boot, boot port using--port parameter option

The main parameters are as follows:

DBPath =/home/mongodb/data
Specifies the directory where the database is stored, and, if not set, the MongoDB root directory, and when the MongoDB is started, A Mongod.lock file is created under the storage directory of the database, which is used to record the current Mongod process number and also to differentiate the process instances of each mongod, so different Mongod process instances cannot use the same dbpath.
LogPath =/home/mongodb/mongodb.log
Specifies the path of the log output, and if Logappend = True is not set, the system clears the original log record and overwrites the existing file.
Logappend = True
Logs are recorded in an append manner
BIND_IP = 192.168.86.111
Specify the binding IP of external services, here specify the IP mode of intranet, if there is no special way to deal with the external network can not be connected.
Port = 27017
Specifies the listener port number for the server, which defaults to 27017, and if a single machine is running multiple mongod processes, you need to specify a different port number for each process.
Fork = True
Specifies that the MongoDB is started in a daemon manner, and if not specified, it is possible to add "&" at the start Mongod command.
Auth = True
Start the authentication mechanism for MONGODB client login.
Master = True
Specifies the main machine from which the machine is primarily from mode.


In general, use a parameter profile to start to remember and view, Note: There is no default startup parameter file , the-F option can specify the location of the configuration file,

First New configuration file:

[Mongodb@localhost bin]$ vi/home/mongodb/mongodb-linux-i686-2.0.0/mongodb.conf
# This is a example config file for MongoDB.
DBPath =/data/db/mongodb
LogPath =
/data/db/mongodb/mongod.log
BIND_IP = 127.0.0.1
Noauth = True
Verbose = False
Fork = True
Nohttpinterface = True
~
</mongodb-linux-i686-2.0.0/mongodb.conf "[New] 8L, 273C written

To manually start the use of a configuration file:
[Mongodb@localhost bin]$ /home/mongodb/mongodb-linux-i686-2.0.0/bin/mongod-f/home/mongodb/ Mongodb-linux-i686-2.0.0/mongodb.conf
All output going to:/data/db/mongod.log

If the MongoDB service is added to the random boot

Vi/etc/rc.local

Use the VI Editor to open the configuration file and add the following line of code to it

/home/mongodb/mongodb-linux-i686-2.0.0/bin/mongod-f /home/mongodb/ Mongodb-linux-i686-2.0.0/mongodb.conf-

-logappend

Start Log information view:

[Root@localhost ~]# Tail-100f/data/db/mongod.log

Thu OCT 20 09:59:18
Thu Oct 09:59:18 [Initandlisten] MongoDB starting:pid=5612 port=27017 dbpath=/data/db 32-bit host=localhost--This is the configured path diameter and host, port
Thu Oct 09:59:18 [Initandlisten]
Thu Oct 09:59:18 [initandlisten] * * note:when using MongoDB bit, you are limited to about 2 gigabytes of data--use memory Size
Thu Oct 09:59:18 [Initandlisten] * * * http://blog.mongodb.org/post/137788967/32-bit-limitations
Thu Oct 09:59:18 [Initandlisten] * * with--journal, the limit is lower
Thu Oct 09:59:18 [Initandlisten]
Thu Oct 09:59:18 [initandlisten] db version v2.0.0, pdfile version 4.5--edition number
Thu Oct 09:59:18 [Initandlisten] git version:695c67dff0ffc361b8568a13366f027caa406222
Thu Oct 09:59:18 [Initandlisten] Build info:linux domu-12-31-39-01-70-b4 2.6.21.7-2.fc8xen #1 SMP Fri Feb 15 12:39:36 EST 2008 i686 Boost_lib_version=1_37
Thu Oct 09:59:18 [Initandlisten] Options: {bind_ip: "127.0.0.1", config: "/home/mongodb/mongodb-linux-i686-2.0.0/ Mongodb.conf ", DBPath:"/data/db ", LogPath:"/data/db/mongod.log ", Noauth:" true "}--Startup parameters
Thu Oct 09:59:18 [Initandlisten] waiting for connections on port 27017--Listening ports
Thu Oct 09:59:18 [websvr] Admin Web console waiting for connections on port 28017--web console Port

This information is useful and important for management and maintenance.


Stop MongoDB must emphasize is never use kill-9 to close the Mongod. So the database will ignore everything and kill the process directly, causing the data file to be corrupted.
The safe method is to use Kill-2 pid to turn off the Mongod, which is when the Mongod process receives the shutdown instructions and waits for the operation to be run or file allocation, and so on, closes all open connections and flushes the cached data to disk before it is formally closed.
The safest way is to use the shutdown command to end
> Use admin
Switched to DB admin
> Db.shutdownserver ();

attached: Windows installation and Configuration reference

Http://tech.it168.com/a2011/0417/1179/000001179081_1.shtml

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.