Installation section
1. installation package
1.1 mongodb-org
The following four packages can be installed automatically
1.2 Mongodb-org-server
Mongod processes and configuration files, launching scripts
1.3 Mongodb-org-mongos
MONGOs process
1.4 Mongodb-org-shell
MONGO Shell
1.5 Mongodb-org-tools
Other MongoDB tools, Mongoimport,mongoexport,mongodump,mongrestore,mongofiles,bsondump,mongooplog,mongoperf,mongostat, Mongotop, (Mongosniff)
2. Script file
2.1/etc/rc.d/init.d/mongod
Startup script
2.2/etc/mongod.conf
Configuration file
3. Install MongoDB
3.1 Configuring Yum Source
/etc/yum.repos.d/mongodb.repo->
[MongoDB]
name=mongodb Repository
baseurl=http:// downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
enabled=1
If it's a 32bit system,
[MongoDB]
Name=mongodb Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/i686/
gpgcheck=0
enabled=1
3.2 Installing MongoDB version
sudo yum install mongodb-org
Install the specified version MongoDB
yum install mongodb-org-2.6.1 mongodb-org-server-2.6.1 mongodb-org-shell-2.6.1 mongodb-org-mongos-2.6.1 mongodb-org-tools-2.6.1
3.3 To avoid the unintended escalation
/etc/yum.conf->
Exclude=mongodb-org,mongodb-org-server,mongodb-org-shell,mongodb-org-mongos, Mongodb-org-tools
4. Run MongoDB
Note the MongoDB default port and the status of the SELinux service.
Data file directory:/var/lib/mongo, log file directory:/var/log/mongo.
Change the/var/lib/mongo and/var/log/mongo permissions to the MongoDB runtime.
4.1 Start MongoDB
sudo service Mongod start
4.2 Confirms MongoDB started successfully
Check the MongoDB log file/var/log/mongodb/mongod.log.
Add MongoDB to boot service:
4.3 Off MongoDB Service
4.4 Restart MongoDB Service
sudo service mongod restart
4.5 Start using MongoDB
Configuration file Section
MongoDB introduces a yaml-based format configuration file. 2.4 Versions were still compatible before.
My MongoDB config file:
systemLog:
destination: file
path: "/var/log/mongo/mongod.log"
quiet: true
logAppend: true
timeStampFormat: iso8601-utc
storage:
dbPath: "/var/lib/mongo"
directoryPerDB: true
indexBuildRetry: false
preallocDataFiles: true
nsSize: 16
# quota:
# enforced: false
# maxFilesPerDB: 8
smallFiles: false
syncPeriodSecs: 60
# repairPath: "/var/lib/mongo/_tmp"
journal:
enabled: true
# debugFlags: 1
commitIntervalMs: 100
processManagement:
fork: true
pidFilePath: "/var/run/mongodb/mongod.pid"
net:
# bindIp: 192.168.11.52
port: 27017
http:
enabled: true
RESTInterfaceEnabled: false
# ssl:
# mode: "requireSSL"
# PEMKeyFile: "/etc/ssl/mongodb.pem"
operationProfiling:
slowOpThresholdMs: 100
mode: "slowOp"
security:
keyFile: "/var/lib/mongo/mongodb-keyfile"
clusterAuthMode: "keyFile"
authorization: "disabled"
replication:
oplogSizeMB: 50
replSetName: "repl_test"
secondaryIndexPrefetch: "all"
/div>
Set options:
1. Systemlog
Integer
The level of log file output is lower.
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 for debugging, which is used to document additional exception logs.
String, default is User
Specifies the device level for syslog log information. You need to specify--syslog to use this option.
All diagnostics logs are sent and will be overwritten by the default reboot.
Boolean
Whether to enable the Append log.
String
Specifies a file or syslog. If specified as a file, you must specify both Systemlog.path
Systemlog.timestampformat
String, default to Iso8601-local
Timestamp format in log information:
Ctime,iso8601-utc,iso8601-local
2. Processmanagement
Processmanagement.pidfilepath
String
Specifies the ID of the process, which is used with--fork, and is not created if it is not specified.
Boolean, default to False
Is that the daemon runs in the background.
3. Net
Interger, defaults to 27017
MongoDB the port number on which the instance listens.
string,2.6 version defaults to 127.0.0.1
Specifies the IP to be bound by the MongoDB instance, separated by commas in order to bind multiple IP.
Net.maxincomingconnections
Integer defaults to 1000000
The maximum number of connections that the MongoDB instance accepts, if higher than the maximum number of threads accepted by the operating system, the setting is invalid.
Boolean, default to True
Check the validity of the document. will affect performance slightly.
Boolean, default to False
Opening the HTTP port can result in more unsafe factors.
Net.unixDomainSocket.enabled
Boolean, default to False
Stop the UNIX domain socket listening.
MongoDB instance listens to UNIX all the time
Socket, Bindip does not have the default designation of 127.0.0.1 unless the net.unixDomainSocket.enabled setting is set to True,bindip.
Net.unixDomainSocket.pathPrefix
string, default to/tmp
The path where the UNIX socket is located.
Boolean, default to False
Turn on the IPV6 feature, which defaults to off.
Boolean, default to False
Running JSON to access the HTTP port can lead to more unsafe factors.
Net.http.RESTInterfaceEnabled
Boolean, default to False
Even if the HTTP interface option is turned off, opening exposes the HTTP interface, which can lead to more unsafe factors.
4. Security
String
A key file storage location that specifies the authentication between a fragment set or a replica set member.
String
This pattern is used in cluster authentication and can be specified here if the X.509 security mechanism is used.
keyfile,sendkeyfile,sendx509,x509
The default MongoDB distributions do not support SSL, and you can use professional editions or recompile MongoDB.
String, default to Disabled
Open the User role authentication that accesses the database and operates.
Enabled,disabled
5. operationprofiling
Operationprofiling.slowopthresholdms
Integer, default 100
Specify a slow query time, in milliseconds, and write data to the System.profile collection if the feature is turned on.
Integer, default 0
Change the parse log output level.
0,1,2, respectively, close, open only slow query, record all operations.
6. Storage
String
Specifies the path to the data file.
Boolean, default shutdown
Specifies that each database file is stored to a separate data directory. If you use this option on an existing system, you need to move the existing data files to the directory beforehand.
Boolean, default to True
Specifies that the database is stopped during the indexing process, and if the index is reset after reboot.
Storage.preallocdatafiles
Boolean, Default True
Do you want to fragment the data file beforehand?
Integer, default 16
Specifies the size of the namespace, which is the file for the. NS suffix. A maximum of 2047mb,16m files can provide approximately 24,000 namespaces.
Boolean, Default False
Limit the number of data files per database. You can adjust the number by Maxfilesperdb.
Storage.quota.maxFilesPerDB
Integer, defaults to 8
Limit the number of data files per database.
Boolean, default to False
Limit the size of the MongoDB data file to 512MB, reduce the journal file from 1G to 128M, and apply to a large number of small data files.
Number, default 60
MongoDB file refresh rate, try not to modify in the production environment.
Storage.repairpath
string, which defaults to the _tmp directory under the specified dbpath.
Specifies the root directory that contains the data file for--repair operations.
Boolean, default 64bit is true,32bit to False
Log action logs to prevent data loss.
Storage.journal.debugFlags
Integer
Provides functional testing of the database under abnormal shutdown.
Storage.journal.commitIntervalMs
Number, defaults to 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 extra 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, after which the time changes to One-third.
7. Replication
Integer, defaults to 5% of the disk
Specifies the maximum size of the oplog. The specified is invalid for a database that has already been established oplog.rs.
String
Specifies the name of the replica set.
Replication.secondaryindexprefetch
String, default to all
Specifies whether the replica set member loads indexes into memory before accepting oplog. All indexes to memory are loaded by default.
None, not loaded; all, loading all; _id_only, loading only _id.
8. sharding
String
Specifies the MongoDB role of the fragment set.
CONFIGSVR, configure server, port 27019;shardsvr, fragment 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
String
Syslog, save authentication in JSON format is not available under Syslog,windows, serverity level is info,facility level is user.
Console, outputting information to standard output in JSON format.
file, which outputs information to files in JSON format.
String
Specify the format of the output file
JSON, output JSON format file; Bson, output bson binary format file.
String
If the value of--auditdestination is file, this option specifies the file path.
Document
The format of the specified filtering system authentication is:
{atype: <expression>}
{atype: <expression>, "param.db": <database>}
Snmp
Boolean
Run SNMP as a child agent.
Boolean
Run SNMP as a master process.
Ps:
1. MONGOs option only
Replication.localpingthresholdms
Integer, default 15
Is affected when the client selects the replica set for read operations.
Boolean
Prevents MONGOs from automatically inserting metadata in a fragmented collection.
Because any mongos can create a separation, if this option is turned on, it will cause fragmentation imbalance and need to be used with caution.
String
Specifies the configuration database. You can use commas to separate one or three servers.
If you are in a different location, you need to specify the nearest one.
The configuration server cannot be removed, even if it is unavailable or offline.
Integer, defaults to 64
The size of each block. 64MB is the ideal size, and small can result in the inability to move efficiently between different nodes.
is only valid when initialized.
2.Windows Service Options
ProcessManagement.windowsService.serviceName
String, default to MongoDB
Specifies the MongoDB service name. You can use the--install,--Remove to add or remove.
ProcessManagement.windowsService.displayName
String, default to MongoDB
Sets the name of the MongoDB service application.
ProcessManagement.windowsService.description
String, default to MongoDB Server
Combined with--install, you must specify a value for this option.
ProcessManagement.windowsService.serviceUser
Specify the user who is running the MongoDB service
ProcessManagement.windowsService.servicePassword
Specify the password for the user running the MongoDB service