MongoDB configuration file

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

Common Configuration methods:

#server ############################ #dbpath =/usr/local/mongodb/mongodb/datalogpath =/usr/local/mongodb/mongodb/ Log/mongod.logpidfilepath =/usr/local/mongodb/mongodb/mongod.pid#append Loglogappend = truefork = Trueport = 27017journal = Truedirectoryperdb = Truesyncdelay = 60maxConns = 10000#httpinterface = true####### #Slow log############## ###### #profile = 0slowms = 5######## #Replaction::::: master####### #master = trueoplogsize = 20480######## #Replaction::: :: slave######## #islave = True#source = 127.0.0.1:27017#autoresync = true####### #Repl set##################### #replSet = gechongrepl/10.0.0.8:27017

  

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:

#[[email protected] mongodb]#./mongod--config=. /mongod.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 = TRUE2.VVVV = trueps: 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 also do not do) error: [MONGO--port=1021 Connection]1.error:listen (): Bind () failed errno:13 Permission denied for socket:127.0.0.1:10211.port = 27017bind_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.1maxConns: 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 = 100objcheck: 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 = true2. #noobjcheck = Falsenoobjcheck: Ditto, false off by default. 1. #noobjcheck = Falselogpath: Specifies the log file that will hold all of the log records and 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.loglogappend: 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=truesyslog: The log output is sent to the host's syslog system instead of 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 Syslog1.syslog = Truepidfilepath: Process ID, no PID file is started when it is not specified. Default defaults. 1.pidfilepath =/var/run/mongo.pidkeyfile: Specifies the path to the key file where the authentication information is stored. Default defaults. See details: "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/keyfilenounixsocket: Socket file, default is False, there is a build socket file. When set to True, the socket file is not generated. 1.nounixsocket = falseunixsocketprefix: Socket file path, default/tmp1.unixsocketprefix =/tmpfork: Whether background is running, set to True daemon mode that starts the process running in the background. False by default. 1.fork = Trueauth: User authentication, default false. No authentication is required. When set to True, entering the database requires AUTH authentication when the databaseThere is no user, you do not need 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 other library operations, can not be verified in other libraries. This connection database also needs to specify the library: 1.MONGO-USA-PSA admin #sa account Connection ADMIN1.MONGO-UAA-PAA Test #aa account Connection Testnoauth: Prohibit user authentication, default true. Ibid. 1.noauth = Truecpu: Set to True will force MongoDB to report CPU utilization and IO waits per 4s, writing log information to standard output or log files. The default is False. 1.CPU = True 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/mongodbdiaglog: 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 value is as follows: 1.Value Setting2.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. #写和一些读操作设置不等于0, the log will flush once every minute: 1. Mon June Ten 11:16:17.504 [Datafilesync] Flushing Diag log2. Mon June 11:17:17.442 [Datafilesync] flushing diag log generated logs can be viewed with Mongosniff: if mongosniff[ 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, it stops writing to the file, but Mongod still 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 = 3directoryperdb: 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 file to the database directory that DIRECTORYPERDB generated, 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 = TURE01. RAW data structure: 02.journal03.mongod.lock04.local.005.local.106.local.ns07.test.008.test.109.test.ns10.11. Open Directoryperdb, and the structure after migrating the data files to the relevant data directory: 12.13.journal14.mongod.lock15.local/local.016.local/local.117.local/ Local.ns18.test/test.019.test/test.120.test/test.nsjournal: Log, (redo log, for more information see here and here) 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 =true2.journal=false32 os:1.tue June 12:17:09.628 [Initandlisten] * * Note:this is a three bit MongoDB binary.2.t UE June 12:17:09.628 [Initandlisten] * * The builds is limited to less than 2GB of data (or less with--journal). 64 bit O S:1.tue June 12:29:34 [Initandlisten] Journal Dir=/var/lib/mongodb/journal2. Tue June 12:29:34 [Initandlisten] recover:no journal files present, no recovery needednojournal: Disable log default: (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=truejournalcommitinterval: Brush Write commit mechanism, default is 30ms or 100ms. Lower values will consume more disk performance. This option accepts values 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=100ipv6: Whether IPv6 is supported, false by default. JSONP: Whether to allow JSONP access via an HTTP interface, the defaultAcknowledge false. Nohttpinterface: Whether to prohibit HTTP interface, that is, 28017 port open service. Default false, supported. 1.nohttpinterface = Falsenoprealloc: 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 = falsenoscripting: Disables scripting engine. The default is false: not forbidden. Ture: Disable 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 = falsenotablescan: Suppresses table scan operations. Default false: No prohibit, ture: Prohibit prohibit if perform a table scan will appear: 1.error: {"$err": "Table scans not allowed:test.emp", "Code": 10111} can modify the settings dynamically: 1.db.adm Incommand ({setparameter:1, notablescan:false}) 1. #notablescan = True <====> Notablescan = falsenssize: 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.02.-rwxrwxrwx 1 mongodb zhoujy 32M June 121:36 test.13.-rwxrwxrwx 1 MongoDB zhoujy 16M June one 14:44 test.ns4.drwxr-xr-x 2 root root 4.0K June 11:57 _tmp1.nssize = 16profile: Database analysis level setting. Record some operational performance to standard output or the specified LogPath log file, default 0: Off. 1. Level set 2.0 off. No analysis. 3.1 Open. Only slow operations are included. 4.2 Open. Includes all operations. Control Profiling switches and levels: 2 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.profile1.> Db.setprofilinglevel (2) 2. {"was": 0, "slowms": +, "OK": 1} 3.> Db.getprofilingstatus () 4. {"was": 2, "SLOWMS": 100} By default, Mongod disables parsing. 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 = 2001.> db.getprofilingstatus () 2. {"was": 2, "slowms":}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 = truequotafiles: Quota quantity. The limit on the number of data files per database. This option requires quota to true. The default is 8. 1.quotaFiles = 8rest: Default false, set to true to make a simple REST API. 1.rest = True set to True after opening in 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, (after opening, 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 repair:1.> db.repairdatabase (' xxx ') 2. {"OK": 1} 3.> db.repairdatabase () 4. {"OK": 1} fixed at startup: 1.repair = true[email protected]:/var/log/mongodb# Mongod--repair Startup Repair, need to close journal, otherwise error: 1.Can ' T specify both--journal and--repair options. And when you start, with the control file specified parameters and the 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 _tmpsmallfiles: 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 = Truesyncdelay: 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 does not synchronize memory-mapped files 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 one 21:07:15.035 page size:40963.tue June one 21:07:15.035 _sc_phys_pages:25631 84.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 = Falsequiet: Quiet mode. 1.quiet = new parameter for truesetparameter:2.4, specifies the startup option configuration. If you want to set more than one option, you can specify it with a setparameter option, please see here for Setparameter parameters, please see here for details Setparameter settings in this file, use the following format: 1.setParameter = < parameter>=<value> Set syncdelay:1.setparameter = syncdelay= 55,notablescan = True in config file, Journalcommitinterval = 50,traceexceptions = truereplication options replication option Replset: Use this setting to configure replica sets. 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 the Mongod is first created oplog, changing the oplogsize will not affect the OPThe size of the log. 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: 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 = Trueslave: Defaults to False when set to true to configure the current instance as slave instance. 1.slave = Truesource: Default is empty and the format is:

  

MongoDB configuration file

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.