MongoDB Database Installation
MongoDB official: Https://www.mongodb.com/download-center
You first need to choose the correct version of MongoDB based on the version of Windows to install, and you can check the Windows version by entering the following instruction on the command line:
WMIC OS get Osarchitecture
+ -bit version of MongoDB only support 2G The following databases are available for testing and evaluation only.
Click on the downloaded installation file to proceed MongoDB database installation, such as: Mongodb-win32-x86_64-2008plus-ssl-3.2.10-signed.msi
after the installation is complete, jump to the command line MongoDB installation directory, enter the following command to check if the installation was successful
Mongod-v
MongoDB needs to create a directory to hold all the data files, by default MongoDB data directory is C:\data\db\ (see above), so you need to create the corresponding folder under the C drive, you can also set the command line
MongoDB's Data Directory
mongod --dbpath "d:\mongodb\data"
The console output is displayed ? waiting for connections? message, which means Mongod The process has run successfully.
There are 2 ways to start MongoDB, one is to specify the configuration parameters directly, and the other is to specify the configuration file
- Specify configuration parameters directly
For example:
mongod --dbpath "d:\mongodb\data"
- Specify the configuration file
Because there is no default configuration file in the official download installation package,If you want to use a configuration file that you can create only yourself, make sure to useASCIIencoding format,Mongod?instance does not support configuration files using non-ASCII?encoding format, includingUTF-8. From2.6version laterMongoDBUseYAMLfile format, note: YAML? tab Indent is not supported:?Replace with a space.
For example:
mongod --config d:\mongodb\mongodb.conf
?
Detailed configuration parameters:
? MongoDB 3.0The configuration file then takesYAMLformat, this format is very simple, using the<key>:<value>indicates that the beginning is used"Space"as indentation. It is important to note that":"Then there arevaluewords that need to be followed by a space ifKeysimply represents a hierarchy, you do not need to":"add spaces (such as:Systemlog:There are no spaces to be followed.) By hierarchy, each line4a space indent, and the second level8spaces, which are pushed in turn, and the top layer does not require a space indent
1. Systemlog
Systemlog.verbosity
Integer
The level of the log file output, the larger the lower the level.
Systemlog.quite
Boolean
The output information is restricted in quite mode:
Database command output, replica set activity, connection accept event, connection Shutdown event.
Systemlog.traceallexceptions
String
Print verbose information to debug, to record additional exception logs.
Systemlog.syslogfacility
String, default to User
Specifies the device level for syslog log information. You need to specify--syslog to use this option.
Systemlog.path string
Sends all diagnostic information logs, which are overwritten by default reboots.
Systemlog.logappend
Boolean
Whether to enable append logs.
Systemlog.logrotate
String
New in V3.0.0 version, default value is rename
Use Rename,mongod or MONGOs to rename the current log file by adding a UTC (GMT) timestamp to the end of the file name, then open the new log file, close the old log file, and send all new log information to the new log file.
Reopen close and reopen the log file follows typical Linux/unix log switching behavior. Use reopen to avoid log loss when using the Linux/unix logrotate tool.
If you specify reopen, you must also use-logappend
?
Systemlog.destination
String
Specifies a file or syslog. If specified as a file, you must specify both Systemlog.path
Systemlog.timestampformat
String, default = Iso8601-local
Timestamp format in the log information:
Ctime,iso8601-utc,iso8601-local
?
2. Processmanagement
Processmanagement.pidfilepath
String
Specifies the ID of the process, which is used in conjunction with--fork and is not created if not specified.
Processmanagement.fork
Boolean, default = False
is the daemon running in the background.
?
3. Net
Net.port
Interger, default is 27017
The port number that the MongoDB instance listens on.
Net.bindip
string,2.6 version defaults to 127.0.0.1
Specifies the IP of the MongoDB instance binding, in order to bind multiple IPs, you can use commas to separate them.
Net.maxincomingconnections
Integer defaults to 1000000
The maximum number of connections accepted by the MongoDB instance, if it is higher than the maximum number of threads accepted by the operating system, the setting is invalid.
Net.wireobjectcheck
Boolean, which is true by default
Check the validity of the document. Performance is slightly affected.
Net.http.enabled
Boolean, default = False
Opening the HTTP port can lead to more unsafe factors.
Net.unixDomainSocket.enabled
Boolean, default = False
Stop UNIX domain socket snooping.
MongoDB instances will always listen to Unix
Socket, unless net.unixDomainSocket.enabled is set to True,bindip not set, Bindip is not specified by default to 127.0.0.1.
Net.unixDomainSocket.pathPrefix
string, default to/tmp
The path where the UNIX socket resides.
Net.ipv6
Boolean, default = False
Turn on the IPV6 feature, which is turned off by default.
Net.http.JSONPEnabled
Boolean, default = False
Running the JSON access HTTP port opens up more unsafe factors.
Net.http.RESTInterfaceEnabled
Boolean, default = False
Even if the HTTP interface option is turned off, opening exposes the HTTP interface, which can lead to more unsafe factors.
?
4. Security
Security.keyfile
String
Specifies the location where the key file for authentication between a shard set or replica set member is stored.
Security.clusterauthmode
String
This mode is used in cluster authentication, which can be specified here if the security mechanism is used.
keyfile,sendkeyfile,sendx509,x509
The default MongoDB release is SSL-free, and you can use the Professional version or recompile your own mongodb.
Security.authorization
String, default = disabled
Open the User role authentication that accesses the database and operates.
Enabled,disabled
?
5. operationprofiling
Operationprofiling.slowopthresholdms
Integer, default 100
Specifies the slow query time, in milliseconds, to write data to the System.profile collection if the feature is turned on.
Operationprofiling.mode
Integer, default 0
Change the analysis log output level.
0,1,2, corresponding to close, open only slow query, record all operations.
?
6. Storage
Storage.dbpath
String
Specifies the path to the data file.
Storage.directoryperdb
Boolean, closed by default
Specifies that each database file is stored to a separate data directory. If you use this option in an existing system, you need to move the existing data file to the directory beforehand.
Storage.indexbuildretry
Boolean, which is true by default
Specifies whether the database is stopped during index creation, and if the index is re-established after a restart.
Storage.preallocdatafiles
Boolean, Default True
Whether to pre-shard good data files.
Storage.nssize
Integer, default 16
Specifies the size of the namespace, which is the. ns suffix file. A maximum of 2047mb,16m files can provide approximately 24,000 namespaces.
storage.quota.enforced
Boolean, Default False
Limit the number of data files per database. You can adjust the number by Maxfilesperdb.
Storage.quota.maxFilesPerDB
Integer, default = 8
Limit the number of data files per database.
Storage.smallfiles
Boolean, default = False
Limit the MongoDB data file size to 512MB, reduce journal files from 1G to 128M, and apply to a number of small data files.
Storage.syncperiodsecs
Number, default 60
MongoDB file refresh rate, try not to modify in the production environment.
Storage.repairpath
A string that defaults to the _tmp directory under the specified dbpath.
Specifies the root directory that contains the data files for--repair operations.
Storage.journal.enabled
Boolean, default 64bit is true,32bit to False
Record the operation log to prevent data loss.
Storage.journal.debugFlags
Integer
Provides functional testing of the database under abnormal shutdown.
Storage.journal.commitIntervalMs
Number, default is 100 or 30
The maximum time interval for journal operations. Can be a value between 2-300ms, a low value helps to persist, but increases the additional burden on the disk.
If the journal and data files are on the same disk, the default is 100ms. If the 30ms is on a different disk.
If you force Mongod to commit the log file, you can specify J:true, and the time becomes the original one-third.
?
7. Replication
Replication.oplogsizemb
Integer, default to 5% of disk
Specifies the maximum size of the oplog. For databases that have already established oplog.rs, the designation is invalid.
Replication.replsetname
String
Specifies the name of the replica set.
Replication.secondaryindexprefetch
String, default to all
Specifies whether the replica set member will load the index into memory before accepting oplog. By default, all indexes are loaded into memory.
None, does not load; all, loads all; _id_only, loads only _id.
?
8. sharding
Sharding.clusterrole
String
Specifies the MongoDB role for the Shard set.
CONFIGSVR, configuring the server, Port 27019;shardsvr, shard instance, Port 27018.
Sharding.archivemovedchunks
Integer
During block move, this option forces the MongoDB instance to save all moved documents to the Movechunk directory.
?
9. Auditlog
Auditlog.destination
String
Syslog, save authentication in JSON format is not available under Syslog,windows, serverity level is info,facility level is user.
Console to output information in JSON format to standard output.
File to output the information in JSON format.
Auditlog.format
String
Specify the format of the output file
JSON, output JSON format file; BSON, output BSON binary format file.
Auditlog.path
String
If the value of--auditdestination is file, this option specifies the path to the files.
Auditlog.filter
Document
Specifies that the format for filtering system authentication is:
{atype: <expression>}
{atype: <expression>, "param.db": <database>}
?
Ten. SNMP
Snmp.subagent
Boolean
Run SNMP as a sub-agent.
Snmp.master
Boolean
Run SNMP as a master process.
?
MONGOs only option
Replication.localpingthresholdms
Integer, default 15
Affected when the client selects the replica set for read operations.
Sharding.autosplit
Boolean
Prevents MONGOs from automatically inserting metadata in a shard collection.
Because any mongos can create a separation, if this option is turned on, it will result in fragmentation of the Shard and need to be used with caution.
Sharding.configdb
String
Specifies the configuration database. You can use commas to separate one to three servers.
If you are in a different location, you need to specify the nearest one.
You cannot remove the configuration server, even if it is not available or offline.
Sharding.chunksize
Integer, default = 64
The size of each block. 64MB is an ideal size and small one can not efficiently move between different nodes.
Only valid at initialization time.
?
Reference Example:
Systemlog: Quiet:true #syslogFacility: <string> Path:d:\mongodb\logs\mongodb.log Logappend:true Destination:file Timestampformat: "ISO8601-UTC" Storage Dbpath:d:\mongodb\data Indexbuildretry:true #repairPath: <string> Journal Enabled:true Directoryperdb:true #syncPeriodSecs: 60 Engine:wiredtiger Wiredtiger: Engineconfig: Cachesizegb:10 Directoryforindexes:true Collectionconfig: Blockcompressor:zlib Indexconfig: Prefixcompression:true #processManagement: #fork: True #pidFilePath: D:\mongodb\run\mongodb.pid Net port:27017 #bindIp: 127.0.0.1 maxincomingconnections:65536 Wireobjectcheck:true Ipv6:false http Enabled:false Jsonpenabled:false Restinterfaceenabled:false #ssl: #mode: <string> #PEMKeyFile: <string> #PEMKeyPassword: <string> #security: #keyFile: D:\mongodb\keyfile #clusterAuthMode: KeyFile #authorization: Disabled Operationprofiling: slowopthresholdms:100 Mode:slowop Replication Oplogsizemb:50 Replsetname:reptestname Secondaryindexprefetch:all #enableMajorityReadConcern: <boolean> #sharding: #clusterRole: <string> #archiveMovedChunks: <boolean> |
MongoDB Learning Notes-database installation and configuration