Vernacular MongoDB (III)

Source: Internet
Author: User
Tags mongodb 32 bit

Source Address http://www.ningoo.net/html/2011/mongodb_in_a_nutshell_2.html by ningoo

After installing MongoDB through source code compilation, You need to configure and run it. In the MongoDB installation directory, there are several sub-directories. The bin contains executable files, including

  • Mongod: database server, similar to mysqld. Each instance starts a process and can run fork as daemon.
  • Mongo: the client command line tool, similar to sqlplus/MySQL, is actually a JS interpreter and supports JS syntax.
  • Mongodump/mongorestore: imports data into a bson file/restores the bson file to a database, similar to xtracbackup
  • Export export/Export Import: export the collection to JSON/CSV format data/import the data into the database, similar to mysqldump/mysqlimport
  • Bsondump: Dump bson files into JSON data
  • Mongos: shard routing. If sharding is used, the application is connected to mongos instead of mongod.
  • Program Files: gridfs management tool
  • Mongostat: Real-time Monitoring Tool

The simplest way is to start the MongoDB Database Service by executing mongod. mongod supports many parameters but has default values. The most important thing is to specify the data file path, or make sure that the default/data/DB exists and has access permissions. Otherwise, the service is automatically disabled after the service is started. OK, that is to say, you only need to ensure that dbpath can start the MongoDB service:

$ ./mongod --dbpath /tmpFri Apr  1 00:34:46 [initandlisten] MongoDB starting : pid=31978 port=27017 dbpath=/tmp 32-bit ** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data**       see http://blog.mongodb.org/post/137788967/32-bit-limitations**       with --dur, the limit is lowerFri Apr  1 00:34:46 [initandlisten] db version v1.8.0, pdfile version 4.5Fri Apr  1 00:34:46 [initandlisten] git version: 9c28b1d608df0ed6ebe791f63682370082da41c0Fri Apr  1 00:34:46 [initandlisten] build sys info: Linux ning 2.6.36-ningoo #1 SMPWed Nov 17 21:45:13 CST 2010 i686 BOOST_LIB_VERSION=1_42Fri Apr  1 00:34:46 [initandlisten] waiting for connections on port 27017Fri Apr  1 00:34:46 [websvr] web admin interface listening on port 28017

The main parameters of mongod include:

Dbpath: data file storage path. Each database creates a sub-directory. The mongod. Lock used to prevent the same instance from running for multiple times is also saved in this directory.
Logpath: Error Log File
Logappend: The append mode is used for error logs (the overwriting mode is used by default)
Bind_ip: the IP address bound to the external service. It is usually set to null and bound to all available IP addresses of the local machine. You can specify the IP address as needed.
Port: External Service port. Web Management port + 1000 based on this port
Fork: run the service in the form of daemon.
Journal: enables the log function to save operation logs to reduce the recovery time of standalone faults. It is officially added after version 1.8 to replace the Dur parameter in version 1.7.5.
Syncdelay: interval at which sync is executed, in seconds.
Directoryperdb: each database is stored in a separate directory. We recommend that you set this parameter.
Maxconns: Maximum number of connections
Repairpath: temporary directory for executing repair. If journal is not enabled and the system restarts after an exception occurs, you must perform the repair operation.

In the source code, mongod parameters include common parameters, Windows parameters, replication parameters, replica set parameters, and implicit parameters. Common parameters are listed above. If you want to configure replication, replica set, and so on, you also need to set the corresponding parameters, which will not be expanded here. A special article will be provided later. Run mongo-help to view the explanation of most parameters. However, some implicit parameters can only be obtained by looking at the code (see dB. CPP Po: options_description hidden_options ("hidden options");), implicit parameters are generally either still under development or ready to be discarded. Therefore, this parameter is not recommended in the production environment.

You may have noticed that the memory size parameter in mongod is not set. Yes, MongoDB uses the OS MMAP mechanism to cache data files. Currently, it does not provide a caching mechanism. The advantage is that the code is simple, and MMAP has a high validity rate when the data volume does not exceed the memory size. However, when the data volume exceeds the available memory of the system, the write performance may be unstable, which may lead to major fluctuations. However, in the latest 1.8 version, this situation has been improved to some extent relative to the previous version. For details, refer to the realzyy test.

So many parameters are easily messy and difficult to manage in the command line. Therefore, mongod also supports writing parameters to a configuration text file like mysqld, and then referencing this configuration file through the config parameter:

./mongod --config /etc/mongo.cnf

So far, a single-host MongoDB instance has been successfully run.

Related Article

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.