mongodb.conf configuration file Detailed

Source: Internet
Author: User
Tags auth mongodb syslog time interval file permissions server port

Looking everywhere to get together.

Can not find who original, if you see call, I added up

There are 2 ways to start MongoDB, one is to specify the configuration parameters directly, and the other is to specify the configuration file. This first introduces the configuration file, which starts as follows:

1.mongod--config/etc/mongodb.conf

The configuration is as follows:

VERBOSE: Log information redundancy. False by default. Improve internal reporting standard output or log files to the LogPath configuration. To enable verbose or enable verbosity with VVVV parameters, such as:

1.verbose = True

2.VVVV = True

PS: Start verbose verbose information, it has a level of vv~vvvvv,v more levels, the more detailed the information recorded in the log file.

Port: Ports. Default 27017,MONGODB default service TCP port, listening for client connections. If the port setting is less than 1024, such as 1021, you need root permission to start, can not be started with the MongoDB account, (ordinary account even 27017 will not do) otherwise error: [MONGO--port=1021 connection]

1.error:listen (): Bind () failed errno:13 Permission denied for socket:127.0.0.1:1021

1.port = 27017

BIND_IP: Bind address. By default 127.0.0.1, only local connections are allowed. The process binds and listens for application connections from this address. If you need to connect to other servers, you need to comment out this or to change the IP address, such as 192.168.200.201[other servers with MONGO--host=192.168.200.201 connection], you can use a comma-delimited list to bind multiple IP addresses.

1.BIND_IP = 127.0.0.1

Maxconns: Maximum number of connections. Default value: Depends on the system (that is, the Ulimit and file descriptor) limits. MongoDB does not restrict its own connections. When the setting is greater than the system limit, it is not valid, whichever is the system limit. This is useful for clients to create many "tables" that allow the connection to time out without closing the table. Set the value above the size of the connection pool and the total number of connections to prevent spikes in the connection. Note: You cannot set this value to greater than 20000.

1.maxConns = 100

Objcheck: Force validation of client requests. The default setting of 2.4 for Objcheck becomes true, and the default is false in earlier versions of Objcheck. Because it forces validation of client requests, ensure that the client never inserts invalid files into the database. For objects with nested documents, there is a little performance impact. Set Noobjcheck off.

1.objcheck = True

2. #noobjcheck = False

Noobjcheck: Ditto, false off by default.

1. #noobjcheck = False

LogPath: Specifies the log file that will hold all the log records, diagnostic information. Unless otherwise specified, Mongod outputs all log information to standard output. If Logappend is not specified, the log will overwrite the operation if it is restarted.

1.logpath=/var/log/mongodb/mongodb.log

Logappend: Write Log mode: set to True for append. The default is overwrite. If this setting is not specified, MongoDB will overwrite the existing log file at startup.

1.logappend=true

Syslog: The log output is sent to the host's syslog system, not the standard output to the LogPath specified log file. Syslog and LogPath can not be used together, will be error:

1.Cant use both a logpath and syslog

1.syslog = True

Pidfilepath: Process ID, no PID file is started when it is not specified. Default defaults.

1.pidfilepath =/var/run/mongo.pid

KeyFile: Specifies the path to the key file that stores the authentication information. Default defaults. For details, see: "

word-spacing:0px; Display:inline; White-space:normal; Orphans:2; Widows:2; Font-size-adjust:none; Font-stretch:normal; Background-color: #ffffff; -webkit-text-size-adjust:auto; -webkit-text-stroke-width:0px; " >replica set Security "and" Replica set administration. "

1.keyFile =/srv/mongodb/keyfile

Nounixsocket: Socket file, default is False, there is a build socket file. When set to True, the socket file is not generated.

1.nounixsocket = False

Unixsocketprefix: Socket file path, default/tmp

1.unixSocketPrefix =/tmp

Fork: Whether it is running in the background, set to True daemon mode that the process runs in the background. False by default.

1.fork = True

Auth: User authentication, default false. No authentication is required. When set to true, access to the database requires Auth authentication, and when there are no users in the database, it is not necessary to verify or operate. Until the first user is created, then the action requires validation.

1.auth = True

For example: Through the Db.adduser (' sa ', ' sa ') under the Admin library to create a super-user, only under the Admin library authentication is complete: Ab.auth (' sa ', ' sa ') to go to another library operation, can not be verified in other libraries. You also need to specify a library to connect to the database:

1.MONGO-USA-PSA Admin #sa Account Connection Admin

1.MONGO-UAA-PAA Test #aa Account Connection test

Noauth: Prohibit user authentication, default true. Ditto

1.noauth = True

CPU: Set to True will force MongoDB to report CPU utilization and IO waits every 4s, writing log information to standard output or log files. The default is False.

1.CPU = True

The open log will appear:

1.Mon June 10:21:42.241 [Snapshotthread] cpu:elapsed:4000 writelock:0%

DBPath: Data storage directory. Default: word-spacing:0px; White-space:normal; Orphans:2; Widows:2; Font-size-adjust:none; Font-stretch:normal; Background-color: #ffffff; -webkit-text-size-adjust:auto; -webkit-text-stroke-width:0px; " >/data/db/

1.dbpath=/var/lib/mongodb

Diaglog: Create a very detailed troubleshooting and diagnostic logging for various errors. Default 0. Set to 1 to generate a diaglog. log file at the beginning of the DBPath directory, his values are as follows:

1.Value Setting

2.0 off.       No logging. #关闭. No records.

3.1 Log write operations. #写操作

4.2 Log read operations. #读操作

5.3 Log Both read and write operations. #读写操作

6.7 Log Write and some read operations. #写和一些读操作

Set not equal to 0, the log will flush once every minute:

1.Mon June 11:16:17.504 [Datafilesync] Flushing diag log

2.Mon June 11:17:17.442 [Datafilesync] Flushing diag log

The resulting log can be viewed with Mongosniff: If mongosniff[is similar to Tcpdump's specific TCP/IP network traffic as a MongoDB] error and specific usage, please see here, before the first execution: Apt-get install Libpcap-dev

[email protected]:/var/lib/mongodb# mongosniff--source diaglog diaglog.51b542a9

Note: When reset to 0, the file is stopped, but Mongod continues to open the file even though it no longer writes to the data file. If you want to rename, move or delete diagnostic logs, you must close the Mongod instance completely.

1.diaglog = 3

Directoryperdb: Set to True to modify the data directory storage mode, each database file is stored in a different folder DBPath the specified directory. With this option, MongoDB can be configured to store data on different disk devices to increase write throughput or disk capacity. The default is False.

Note: If this parameter is turned on in a database that is running for a period of time, the original data will disappear (the comment parameter will be returned). Because the data catalog is different, unless you migrate the existing data files into the database directory that DIRECTORYPERDB produces, such as:

[email protected]:/var/lib/mongodb# MV test.* test/

Migrate the test data file to the database test directory generated by Directoryperdb. So you need to decide if you want to open it after planning.

1.directoryperdb = ture

01. RAW Data structure:

02.journal

03.mongod.lock

04.local.0

05.local.1

06.local.ns

07.test.0

08.test.1

09.test.ns

10.

11. Start Directoryperdb and migrate the data files to the relevant data directory after the structure:

12.

13.journal

14.mongod.lock

15.local/local.0

16.local/local.1

17.local/local.ns

18.test/test.0

19.test/test.1

20.test/test.ns

Journal: Log, (redo log, see here and here for more information)

Default value: (on 64-bit system) true.

Default value: (32-bit system) false.

Set to True to enable the action log to ensure write persistence and data consistency, creating the journal directory under the DBPath directory.

Set to False to prevent log persistence without the overhead. In order to reduce the impact of logs used on disk, you can enable nojournal and set to true.

Note: Disabling the log on a 64-bit system must use a nojournal.

1. #journal =true

2.journal=false

32-bit OS:

1.Tue June 12:17:09.628 [Initandlisten] * * Note:this is a A-bit MongoDB binary.

2.Tue June 12:17:09.628 [Initandlisten] * * [builds] is limited to less than 2GB of data (or less with--jour NAL).

64-bit OS:

1.Tue June 12:29:34 [Initandlisten] Journal Dir=/var/lib/mongodb/journal

2.Tue June 12:29:34 [Initandlisten] recover:no journal files present, no recovery needed

Nojournal: Disable Log

Default value: (on 64-bit system) false.

Default value: (32-bit system) true.

Set Nojournal to True to turn off the log, 64 bit, 2.0 after the MONGODB default is enabled journal log.

1.nojournal=true

Journalcommitinterval: Brush Write commit mechanism, default is 30ms or 100ms. Lower values will consume more disk performance.

This option accepts a value between 2 and 300 milliseconds:

If a single device provides logs and data files, the default journal commit time interval is 100 milliseconds.

If the log and data files are provided by different block devices, the default journaling commit time interval is 30 milliseconds.

1.journalcommitinterval=100

IPv6: Whether IPv6 is supported, false by default.

JSONP: Whether to allow JSONP access through an HTTP interface, false by default.

Nohttpinterface: Whether to prohibit HTTP interface, that is, 28017 port open service. Default false, supported.

1.nohttpinterface = False

Noprealloc: Pre-distribution mode.

Default false: Use pre-allocation to ensure stable write performance, pre-allocation is performed in the background, and each pre-allocated file is populated with 0. This allows MongoDB to always keep extra space and free data files, thus avoiding the congestion caused by the allocation of disk space due to the rapid growth of data.

Setting noprealloc= True to disable pre-allocated data files can shorten the startup time, but during normal operation it can cause significant performance degradation.

1.noprealloc = False

Noscripting: Whether the scripting engine is forbidden. The default is false: not forbidden. Ture: Forbidden

If set to true: When running some scripts, it will appear:

1.JavaScript Execution Failed:group command failed: {"OK": 0, "errmsg": "Server-side JavaScript execution is disabled" }

1. #noscripting = True <====> noscripting = False

Notablescan: Whether the table scan operation is forbidden. Default false: Not forbidden, ture: Forbidden

Disable if performing a table scan will appear:

1.error: {"$err": "Table scans not allowed:test.emp", "Code": 10111}

You can modify the settings dynamically:

1.db.admincommand ({setparameter:1, notablescan:false})

1. #notablescan = True <====> Notablescan = False

Nssize: The default size of the file (that is, NS) of the namespace, default 16M, Maximum 2G.

The file (that is, NS) for all newly created default size namespaces. This option does not affect the size of the existing namespace file. The default value is 16M bytes and the maximum size is 2 GB. Let the small database not waste too much disk space, while the big data on the disk to have continuous space.

1.-RWXRWXRWX 1 MongoDB zhoujy 16M June one 14:44 test.0

2.-RWXRWXRWX 1 MongoDB zhoujy 32M June 1 21:36 test.1

3.-RWXRWXRWX 1 MongoDB zhoujy 16M June one 14:44 test.ns

4.drwxr-xr-x 2 root root 4.0K June 11:57 _tmp

1.nssize = 16

Profile: Database analysis level settings. Record some operational performance to standard output or the specified LogPath log file, default 0: Off.

1. Level setting

2.0 off. No analysis.

3.1 Open. Only slow operations are included.

4.2 Open. Includes all operations.

Switch and level of control Profiling: 2 kinds

The first is to set directly in the startup parameters or start MongoDB with the –profile= level, whose information is stored in the generated system.profile.

1.profile = 2

The second is to configure the client in real time with the Db.setprofilinglevel (level) command, whose information is stored in the generated system.profile.

1.[initandlisten] Creating profile Collection:local.system.profile

1.> Db.setprofilinglevel (2)

2.{"was": 0, "slowms": +, "OK": 1}

3.> Db.getprofilingstatus ()

4.{"was": 2, "SLOWMS": 100}

By default, the Mongod analysis is disabled. Database analysis can affect the performance of a database because the parser must record and handle all database operations. So you can use dynamic modification when you need it.

SLOWMS: The time to log slow queries for profile analysis, which is 100 milliseconds by default. specifically ibid.

1.SLOWMS = 200

1.> Db.getprofilingstatus ()

2.{"was": 2, "SLOWMS": 200}

Quota: Quota, false by default. Whether to turn on the limit for configuring the maximum number of files per database. When True, Quotafiles is used to configure the maximum number of files.

1.quota = True

Quotafiles: Number of quotas. The limit on the number of data files per database. This option requires quota to true. The default is 8.

1.quotaFiles = 8

Rest: Default False, set to true to make a simple REST API.

1.rest = True

Set to True, when on, the MongoDB default will open an HTTP protocol port to provide rest service (Nohttpinterface = False), this port is your server port plus 1000, or 28017, The default HTTP port is the Database Status page, (when enabled, commands in the commands line of the Web page can be ordered in). MongoDB comes with rest, does not support add, delete, change, but also does not support authorization authentication.

See here and here for more information.

Repair: Fixed database operation, default is False.

When set to True, repair all databases after startup, it is best to set this option on the command line rather than in the configuration file or control script. Such as:

Command-line FIX:

1.> db.repairdatabase (' xxx ')

2.{"OK": 1}

3.> Db.repairdatabase ()

4.{"OK": 1}

Fix at startup:

1.repair = True

[email protected]:/var/log/mongodb# mongod--repair

Repair at startup, need to close journal, otherwise error:

1.Can ' t specify both--journal and--repair options.

And when started, with the control file specified parameters and configuration file specified parameters in the manner of repair, (repair information see log), you need to disable the repair parameter to enable MongoDB.

Note: When Mongod is repaired, all database files need to be rewritten. If the repair cannot be run under the same account, you will need to run Chown to modify the database file permissions.

Repairpath: Fix path, default is _tmp directory under DBPath path.

1.drwxr-xr-x 2 root root 4.0K June 20:23 _tmp

Smallfiles: Whether to use a smaller default file. The default is False, not used.

Set to true to use a smaller default data file size. Smallfiles reduces the initial size of data files and restricts them to 512M, also reduces the size of log files and restricts them to 128M.

If the database is large, holding a small amount of data will cause MongoDB to create many files that can affect performance.

1.smallfiles = True

Syncdelay: Writes the data to the log frequency, through the Fsync operation data. The default is 60 seconds.

1.syncdelay = 60

The default is yes, no setting is required. Does not affect the log file (journal files)

Warning: If set to 0,syncdelay, the memory-mapped file will not be synchronized to disk. Do not set this value on the production system.

SysInfo: System Information, default false.

Set to True,mongod will diagnose the system about the size of the page, the number of physical pages, available physical?? The number of pages is output to standard output.

1.Tue June 21:07:15.031 SysInfo:

2.Tue June 21:07:15.035 Page size:4096

3.Tue June 21:07:15.035 _sc_phys_pages:256318

4.Tue June 21:07:15.035 _sc_avphys_pages:19895

When the SysInfo parameter is turned on, only the above information will be printed and the MONGODB program will not start. So to turn off this parameter, you can turn on MongoDB.

Upgrade: Upgrade. The default is False.

When set to True, specify DBPath to upgrade the data format files on the disk to the latest version. Affects database operations and updates metadata. In most cases, you do not need to set this value.

Traceexceptions: Whether to use internal diagnostics. False by default.

1.traceExceptions = False

Quiet: Quiet mode.

1.quiet = True

A new parameter for the setparameter:2.4 that specifies the startup option configuration. If you want to set multiple options, you can specify them with a setparameter option, please see here for the setparameter parameters, please see here for details.

Declare the Setparameter settings in this file, using the following format:

1.setParameter = <parameter>=<value>

Set Syncdelay in the configuration file:

1.setParameter = syncdelay= 55,notablescan = True,journalcommitinterval = 50,traceexceptions = True

Replication Options Copy option

Replset: Use this setting to configure the replica set. Specify a replica set name as a parameter, and all hosts must have the same name as the same replica set.

Oplogsize: Specifies the maximum size of the replication operation log (OPLOG). Mongod creates a oplog size based on the maximum amount of free space. For 64-bit systems, Oplog is typically 5% of the available disk space.

Once Mongod creates Oplog for the first time, changing the oplogsize will not affect the oplog size.

Fastsync: The default is False. Under replica set, set to true to enable from the Library Replication Service from a dbpath, the DBPath database is a snapshot of the main library and can be used to quickly enable synchronization, otherwise Mongod will attempt to perform the initial synchronization. Note: If the data is not fully synchronized, Mongod specifies that Fastsync is turned on, secondary or slave is not in sync with the master permanently, which can cause significant consistency issues.

The new parameter that appears in the replindexprefetch:2.2 version, which defaults to all. The values that can be set are: all, none, and _id_only. Can only be used in replica sets (Replset). By default, members of the secondary replica set will load all indexes into memory (related to operations prior to Oplog). You can modify this behavior so that secondary only loads the _id index. Specifies _id_ or none to prevent any index of mongod from being loaded into memory.

Master/slave Replication: Related settings for master-slave replication

Master: The default is False, and when set to true, configures the current instance as the primary instance.

1.master = True

Slave: The default is False when set to true to configure the current instance as slave instance.

1.slave = True

Source: Default is empty, formatted as:

1.source = 127.0.0.1:30001

Only: Default is NULL, which is used to specify a database for replication from the options.

1.only = ABC #只同步abc集合 (library)

Slavedelay: Sets the delay time for synchronizing the main library from the library, which is set from the default of 0.

1.slavedelay = #延迟60s同步主数据

Autoresync: The default is False, which is used to set from. Whether to automatically resynchronize. Set to True if the master is more than 10 seconds behind, forcing automatic resynchronization from. If the oplogsize is too small, there may be a problem with this setting. If the Oplog size is not large enough to store the difference between the change state of the master and the change from the state, forcing resynchronization in this case is not necessary. When the Set Autoresync option is set to false,10 in minutes, no automatic resynchronization is made greater than 1 times.

1.autoresync = False

mongodb.conf configuration file Detailed

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.