|
注:配置参数是分级式的,比如net.http.RESTInterfaceEnabled其实在mongodb.conf中配置为:
net:
port: 27017
bindIp: 127.0.0.1
http:
enabled: true
RESTInterfaceEnabled: false
所有下面都以net.http.RESTInterfaceEnabled这种方式介绍
参数类型一共三种:
string 字符串
boolean 布尔型 false/true
integer 整形
1、systemLog 选项如下:
systemLog.verbosity --用法:verbosity:
日志文件输出的级别,越大级别越低,默认是0
systemLog.quiet --用法: quite: boolean
在quite模式下会限制输出信息:
数据库命令输出,副本集活动,连接接受事件,连接关闭事件。
systemLog.traceAllExceptions --用法:traceAllExceptions: boolean
打印用于调试的详细信息。 用于其他日志记录以进行支持相关的故障排除。
systemLog.syslogFacility --用法:syslogFacility: string,默认为user
指定syslog日志信息的设备级别,需要指定--syslog来使用这个选项。
systemLog.logAppend --用法:logAppend: boolean
是否启用追加日志
systemLog.destination --用法:destination:string ,默认为file
指定一个文件或syslog。如果指定为文件,必须同时指定systemLog.path
systemLog.path --用法:path: string 比如:/var/log/mongodb/mongod.log
日志路径
systemLog.logRotate --用法:logRotate: string ,默认值为rename,另一个是reopen
可以实现rotage日志,实现日志切割
systemLog.timeStampFormat --用法:timeStampFormat: string 默认值为 iso8601-local
日志消息中时间戳的时间格式。还有ctime、iso8601-utc格式
2、storage 选项用法:
范例:
storage:
dbPath:
indexBuildRetry:
repairPath:
journal:
enabled:
commitIntervalMs:
directoryPerDB:
syncPeriodSecs:
engine:
mmapv1:
preallocDataFiles:
nsSize:
quota:
enforced:
maxFilesPerDB:
smallFiles:
journal:
debugFlags:
commitIntervalMs:
wiredTiger:
engineConfig:
cacheSizeGB:
journalCompressor:
directoryForIndexes:
collectionConfig:
blockCompressor:
indexConfig:
prefixCompression:
inMemory:
engineConfig:
inMemorySizeGB:
具体参数的解释:
storage.dbPath --用法:dbPath: string 默认是/data/db(linux) ;\data\db (windows)
注意:如果是yum安装的mongodb,默认是/var/lib/mongo
mongodb数据存储的路径
storage.indexBuildRetry --用法:indexBuildRetry: boolean 默认值是true
指定数据库在索引建立过程中停止,重启后是否重新建立索引。
storage.repairPath --用法:repairPath: string 默认值是:A _tmp_repairDatabase_ ( directory under the dbPath. )
在--repair操作期间MongoDB将使用的工作目录。当--repair结束后,storage.repairPath 目录变为空
注:storage.repairPath设置仅可用于mongod。
storage.journal.enabled --用法:journal.enabled: boolean
64bit操作系统默认为true,32bit操作系统默认为false
启用或禁用持久性日志以确保数据文件保持有效和可恢复,此选项仅在您指定--dbpath选项时适用。
storage.journal.commitIntervalMs --用法:journal.commitIntervalMs: number
mongod进程在日志操作之间允许的最大时间(以毫秒为单位),较低的值会增加日志的持久性,但会降低磁盘性能。
范围是1-500,默认值是100 毫秒。
storage.directoryPerDB --用法:directoryPerDB: boolean 默认值时false
当为true时,MongoDB使用单独的目录来存储每个数据库的数据,目录位于storage.dbPath目录下,每个子目录名称对应于数据库名称。
storage.syncPeriodSecs --用法:syncPeriodSecs: number 默认为60,不要设置为0
MongoDB通过fsync操作将数据刷新到数据文件之前可以经过的时间量。
特别注意:不要在生产系统上设置此值
storage.engine --用法: engine: wiredTiger 默认值为wiredTiger
设置mongodb的存储引擎。还有mmapv1和inMemory
storage.wiredTiger.engineConfig.cacheSizeGB --用法:cacheSizeGB: float
WiredTiger将用于所有数据的内部缓存的最大大小。值的范围可以从256MB到10TB,可以是浮点数。 此外,默认值也已更改。
从3.4开始,WiredTiger内部缓存默认使用以下两者中较大的一个:
50% of RAM minus 1 GB(50%的RAM减去1 GB), or 256 MB.
3、net 选项用法:
net:
port:
bindIp:
maxIncomingConnections:
wireObjectCheck:
ipv6:
unixDomainSocket:
enabled:
pathPrefix:
filePermissions:
http:
enabled:
JSONPEnabled:
RESTInterfaceEnabled:
ssl:
sslOnNormalPorts: # deprecated since 2.6
mode:
PEMKeyFile:
PEMKeyPassword:
clusterFile:
clusterPassword:
CAFile:
CRLFile:
allowConnectionsWithoutCertificates:
allowInvalidCertificates:
allowInvalidHostnames:
disabledProtocols:
FIPSMode:
net.port --用法 port: integer 默认值是27017
mongodb监听的端口
net.bindIp --用法 bindIp: string 默认值是127.0.0.1
mongodb监听的ip地址,也可以自定义
net.maxIncomingConnections --用法:maxIncomingConnections: integer 默认值是65536
mongos或mongod将接受的最大并发连接数,如果此设置高于操作系统配置的最大连接跟踪阈值,则此设置不起作用。
net.wireObjectCheck --用法:wireObjectCheck: boolean 默认值是true
为true时,mongod或mongos实例验证客户端收到的所有请求,以防止客户端将错误格式或无效的BSON插入到MongoDB数据库中。
注意:对于具有高度子文档嵌套的对象,net.wireObjectCheck对性能有轻微影响。
net.http.enabled --用法:enabled: boolean 默认值是false
启用或禁用HTTP接口。 启用接口可能会增加网络暴露。
net.http.RESTInterfaceEnabled --用法:RESTInterfaceEnabled: boolean,默认为false
即使http接口选项关闭,打开也会暴露http接口,会导致更多的不安全因素。不过开启为true可以在
mongodb的web页面访问List all commands 页面!
net.unixDomainSocket.enabled --用法 unixDomainSocket.enabled: boolean 默认值是true
在UNIX域套接字上启用或禁用侦听。 net.unixDomainSocket.enabled仅适用于基于Unix的系统。
4、security 选项
security:
keyFile:
clusterAuthMode:
authorization:
transitionToAuth:
javascriptEnabled:
redactClientLogData:
sasl:
hostName:
serviceName:
saslauthdSocketPath:
enableEncryption:
encryptionCipherMode:
encryptionKeyFile:
kmip:
keyIdentifier:
rotateMasterKey:
serverName:
port:
clientCertificateFile:
clientCertificatePassword:
serverCAFile:
ldap:
servers:
bind:
method:
saslMechanism:
queryUser:
queryPassword:
useOSDefaults:
transportSecurity:
timeoutMS:
userToDNMapping:
authz:
queryTemplate:
security.keyFile --用法:keyFile: string
密钥文件的路径,该文件存储MongoDB实例用于在分片集群或副本集中彼此进行身份验证的共享密钥
keyFile意味着security.authorization!
security.clusterAuthMode --用法: clusterAuthMode: string 默认值是keyFile
用于集群身份验证的身份验证模式
security.authorization --用法:authorization: string 默认值是disabled
启用或禁用基于角色的访问控制(RBAC)以管理每个用户对数据库资源和操作的访问。
enabled: 用户只能访问已为其授予了权限的数据库资源和操作。
diabled: 用户可以访问任何数据库并执行任何操作
security.transitionToAuth --用法:transitionToAuth: boolean 默认值是false
3.4版本新的功能,允许mongod或mongos接受和创建到部署中的其他mongod和mongos实例的已验证和未验证的连接
security.javascriptEnabled --用法:javascriptEnabled: boolean 默认值是true
启用或禁用服务器端JavaScript执行,禁用时,不能使用执行服务器端执行JavaScript代码的操作,例如$ where查询运算符,mapReduce命令和db.collection.mapReduce()方法,group命令和db.collection.group()方法 。
5、setParameter 选项
设置MongoDB服务器参数中描述的MongoDB参数或参数
要在YAML配置文件中设置参数,请使用以下格式:
setParameter:
:
:
例如,要在配置文件中指定enableLocalhostAuthBypass
setParameter:
enableLocalhostAuthBypass: false
6、operationProfiling 选项
operationProfiling:
slowOpThresholdMs:
mode:
operationProfiling.slowOpThresholdMs --用法:slowOpThresholdMs: integer 默认值是100
数据库概要分析器认为查询速度缓慢的阈值(以毫秒为单位),MongoDB将所有慢查询记录到日志中,即使数据库分析器关闭
当分析器打开时,它将写入system.profile集合
operationProfiling.mode --用法:mode: string 默认值是 off
数据库概要分析的级别,它将有关操作性能的信息插入到system.profile集合中。它的值有off、slowOp、all
注意:数据库分析可能会影响数据库性能。 仅在仔细考虑后才启用此选项
7、replication 选项
replication:
oplogSizeMB:
replSetName:
secondaryIndexPrefetch:
enableMajorityReadConcern:
replication.oplogSizeMB --用法:oplogSizeMB: integer
复制操作日志的最大大小(以兆字节为单位),例如:oplog。mongod进程基于可用的最大空间量创建oplog
对64bit系统而言,oplog通常是可用磁盘空间的5%,一旦mongod第一次创建oplog,更改replication.oplogSizeMB选项将不会影响oplog的大小
replication.replSetName --用法: replSetName: string
mongod所属的副本集的名称。 副本集中的所有主机必须具有相同的集名称。如果应用程序连接到多个副本集,则每个副本集应具有不同的名称。 某些驱动程序按副本集名称对副本集连接进行分组。
replication.secondaryIndexPrefetch --用法:secondaryIndexPrefetch: string 默认值是all
存储引擎特定功能:
replication.secondaryIndexPrefetch仅适用于mmapv1存储引擎。
replication.enableMajorityReadConcern --用法: enableMajorityReadConcern: boolean 默认是false
启用“多数”的读取关注级别。
8、sharding 选项
sharding:
clusterRole:
archiveMovedChunks:
sharding.clusterRole --用法:clusterRole: string
mongodb实例在分片集群中具有的角色。有2个值,如下:
configsvr:将此实例作为配置服务器启动。 默认情况下,实例在端口27019上启动。
shardsvr: 将此实例作为分片启动。 默认情况下,实例在端口27018上启动。
sharding.archiveMovedChunks --用法: archiveMovedChunks:boolean
在块迁移期间,分片不保存从分片迁移的文档。
9、auditLog 选项
仅在MongoDB Enterprise中可用
auditLog:
destination:
format:
path:
filter:
还有很多其他参数,这里不一一介绍了!
|
|
|
|
|
|
|