Some explanation of the parameters about MongoDB

Source: Internet
Author: User
Tags mongodb port number


Transferred from://http://f.dataguru.cn/thread-133804-1-1.html


In personal computers, especially virtual machines, proper use of parameters can speed up process startup and reduce disk footprint
Such as
Mongod--replset ABC--dbpath 1--port 27001--oplogsize---logpath log.1--logappend--fork--smallfiles--nojournal

--replset cluster Name
--dbpath data File storage directory
-port Port
--oplogsize operation Log, set up here 50M, for the experimental environment enough, the production environment is generally the default is good, 5% of the disk space, of course, the bigger the better
--logpath log files
--logappend Append log mode
--fork Background Run
--smallfiles using small files
--nojournal do not log operation logs

Use the above command to start MongoDB quickly and take up a small footprint





##################### Split Line #############################

Quick build of MongoDB replica set reprinted from: http://www.cnblogs.com/zjhptxl/p/3365685.html

Before you make a configuration replica set, make a point of starting a single Mongod instance to enable security authentication as long as you add a--auth boot parameter at boot time, but the security authentication of the replica set is not so. He needs another boot parameter--keyfile plus your key file path. The content generation of the key file can be randomly generated using the Linux command the permissions of the Rand-base64 741 generated key file must be set to a file without user groups and other permissions otherwise your MONGO instance will not start to remember!!!! Reference http://docs.mongodb.org/manual/tutorial/generate-key-file/the configuration process for a replica set is broadly divided into two steps1) Launch instance 2) Initializing the replica setconfiguration procedures for replica sets1. Start three instances there is a quorum nodeMongod--rest--replset rs--port 40000--dbpath/var/lib/mongodb/mongonode1--directoryperdb--fork--logpath/var/log/m Ongo/mongodnode1.log--keyfile/root/authfile mongod--rest--replset rs--port 40001--dbpath/var/lib/mongodb/ Mongonode2--directoryperdb--fork--logpath/var/log/mongo/mongodnode2.log--keyfile/root/authfile mongod--rest-- Replset rs--port 40002--dbpath/var/lib/mongodb/mongoarbiter--fork--logpath/var/log/mongo/mongodarbiter.log-- Nojournal--keyfile/root/authfile Of course you can also use the configuration file to start 3 copies of the configuration as follows
# mongonode1.conf Logpath=/var/log/mongo/mongodnode1.log logappend=true fork = true port = 40000 Dbpath=/var/lib/mongo Db/mongonode1 directoryperdb=true replset=rs keyfile=/root/authfile rest=true
# mongonode2.conf Logpath=/var/log/mongo/mongodnode2.log logappend=true fork = true port = 40001 Dbpath=/var/lib/mongo Db/mongonode2 directoryperdb=true replset=rs keyfile=/root/authfile rest=true
# mongoarbiter.conf Logpath=/var/log/mongo/mongodarbiter.log logappend=true fork = true port = 40002 dbpath=/var/lib/m Ongodb/mongoarbiter nojournal=true Nohttpinterface = True Replset=rs keyfile=/root/authfile rest=true
2. Connect to an instance of a non-quorum node for initializationTo initialize a replica set, there are 3 ways to: 1) db.runcommand ({replsetinitiate: <config_object>}) 2) rs.initiate (<config_object>) 3 ) rs.initiate ()//initialization, and then through Rs.add, Rs.remove and other methods of modification began to execute the following command cfg={"_id": "RS", "members": [{"_id": 0, "host": "192.168 .247.45:40000 "}]} rs.initiate (CFG) rs.add (' 192.168.247.45:40001 ') rs.add (' 192.168.247.45:40002 ', {ariterOnly:true} )Simple TestExecute the following script on the master node for (Var i=0;i<1000;i++) {Db.zjh.insert ({name: ' MONGO ' +i,count:1-i});} rs:primary> Db.zjh.ensureIndex ({count:1}); To view from a node instance properly synchronized to this point your replica set is ready for your various tests.members Array member property description (default value in parentheses):_id:Each member in the replica set must have a _id representation that this _id is usually a number that grows from 0 onwards. It is important to note that when one of the members retires (referred to as removed from the replica set config), the newly added member cannot reuse the retired member's _id;Host:IP address and port number;Arbiteronly (false):If true, indicates that the member is the quorum node and does not receive data;Buildindexes (true):If set to False, it prevents the creation of a second index on this node, which is usually used as a purely data backup and is never queried. But also because this node does not have a second index, so he writes very few things, also need very little memory and disk. The index of the _id will still be created. This option is not normally used when the priority property is set to 0 o'clock, which can be set to false.hidden (false):If this is true, do not tell the client that this node exists, the reason for setting the hidden node is that this node's data usage pattern and other nodes are very different, such as: reports, statistics, backup and so on. When set to Ture, allows you to send non-primary queries against this node.Priority (1.0):Weights, higher weights will be elected as the primary nodetags ({}):A document represents the location of this server and facilitates location-aware reading and writing. In fact, it means that this node is located in the data center, MONGODB will synchronize data according to the Data center node that the tags find near.slavedelay (0):The delay of synchronizing data, set to 0, means that synchronization data is updated immediately.votes (1):The number of votes that this node can emit, generally without modifying hisSettings object:Settings objects can be set up again after the cluster is established, typically using default values








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.