mongodb之配置
生活随笔
收集整理的這篇文章主要介紹了
mongodb之配置
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
前言
最新版本支持yaml格式的配置文件,只支持空格,不能使用tab
?
詳細配置說明
?
#系統日志配置 systemLog:destination: filepath: /var/log/mongodb/mongod.loglogAppend: true#quiet模式運行,建議設置為false,方便排查錯誤quiet: false #進程管理 processManagement:#進程后臺運行fork: true #進程pid文件 pidFilePath: /var/log/mongodb/mongod.pid #網絡配置 net:#監聽端口port: 27017 #監聽網卡 多個使用英文逗號隔開bindIp: 127.0.0.1 #最大并發連接數 默認65535maxIncomingConnections: 65535#驗證客戶端傳過來的數據,文檔嵌套多時,對性能會有些影響wireObjectCheck: true #是否啟用ipv6,默認不啟用ipv6: false unixDomainSocket:#是否啟用socket監聽 默認trueenabled: true #socket保存目錄,默認/tmppathPrefix: /var/log/mongodb#socket文件權限,默認0700filePermissions: 0700 http:#是否啟用http服務,默認false,安全考慮線上環境要關閉enabled: false #是否啟用http jsonp,默認false,即使http.enabled為false,只要此項為true,一樣可以訪問,安全考慮線上環境要關閉JSONPEnabled: false #是否啟用rest api接口,默認false,安全考慮線上環境要關閉RESTInterfaceEnabled: false ssl:#type:string#是否啟用加密#可選值1 disabled:禁用#可選值2 allowSSL:優先使用非加密,但是服務器支持加密#可選值3 preferSSL:優先使用加密,但是服務器也支持非加密#可選值4 requireSSL:只支持加密mode: disabled #type:string#包含TLS/SSL certificate and key的文件路徑#包含公鑰和私鑰PEMKeyFile: /var/log/mongodb/mongodb.pem#type:string#私鑰加密時的密碼PEMKeyPassword: password#type:string#The .pem file that contains the x.509 certificate-key file for membership authentication for the cluster or replica set.#不存在會使用PEMKeyFileclusterFile: /var/log/mongodb/cluster.pem#type:string#The password to de-crypt the x.509 certificate-key file specified with --sslClusterFileclusterPassword: password#type:string#The .pem file that contains the root certificate chain from the Certificate Authority.CAFile: #type:string#The the .pem file that contains the Certificate Revocation List.CRLFile: #type:boolean#Enable or disable the requirement for TLS/SSL certificate validation that CAFile enablesallowConnectionsWithoutCertificates: true #type:boolean#Enable or disable the validation checks for TLS/SSL certificates on other servers in the cluster and allows the use of invalid certificates.allowInvalidCertificates: false #type:boolean#是否允許無效的域名,當為true時,mongod不檢查證書里面域名的有效性,即使域名不匹配,mongod同樣允許連接mongodb實例allowInvalidHostnames: false #type:string#禁用加密協議版本,多個使用英文逗號隔開#可設置的值TLS1_0, TLS1_1, and TLS1_2disabledProtocols: #type:string#Enable or disable the use of the FIPS mode of the installed OpenSSL library for the mongos or mongod.FIPSMode: false compression:#是否啟用數據壓縮compressors: snappy#安全配置 security:#type:string#密鑰路徑,副本集和分片集群節點間授權時使用的密鑰keyFile:#type:string #集群授權模式,默認keyFile,值列表:keyFile,sendKeyFile,sendX509,x509clusterAuthMode: keyFile #type:string#是否開啟數據庫訪問RBAC權限控制,默認:disabled,僅對mongod命令有效authorization: enabled #type:boolean#Allows the mongod or mongos to accept and create authenticated and non-authenticated connections to and from other mongod and mongos instances in the deployment.transitionToAuth: false #type:boolean#是否開啟服端js執行,默認true,如果未開啟$where,group,mapreduce都不能使用javascriptEnabled: true #type:boolean#寫日志之前是否編輯客戶端日志數據,去除日志中的敏感數據,僅企業版支持redactClientLogData: true #key管理配置 security:#type:boolean#WiredTiger存儲引擎是否啟用加密,默認false,僅企業版支持enableEncryption: false #type:string#加密模式,默認AES256-CBC,僅企業版支持encryptionCipherMode: AES256-CBC #type:string#密鑰文件路徑,僅企業版支持encryptionKeyFile: /var/log/mongodb/encKeyFile #kmip key server,僅企業版支持kmip: #type:string#Unique KMIP identifier for an existing key within the KMIP server.keyIdentifier: #type:boolean#If true, rotate the master key and re-encrypt the internal keystorerotateMasterKey: false #type:string#Hostname or IP address of key management solution running a KMIP server.serverName: #type:int#Port number the KMIP server is listening onport: 5696 #type:string#String containing the path to the client certificate used for authenticating MongoDB to the KMIP server.clientCertificateFile: #type:string#The password to decrypt the client certificate, used to authenticate MongoDB to the KMIP server.clientCertificatePassword: #type:string#Path to CA File. Used for validating secure client connection to KMIP server.serverCAFile: #sasal配置 security:sasl:hostName: "" #A fully qualified server domain name for the purpose of configuring SASL and Kerberos authentication. serviceName: "" #Registered name of the service using SASL. saslauthdSocketPath: "" #The path to the UNIX domain socket file for saslauthd#setParameter配置 setParameter:enableLocalhostAuthBypass: false#存儲配置 storage:#type:string#數據庫數據存儲目錄,默認/data/dbdbPath:#type:boolean#啟動時是否嘗試重建索引,默認trueindexBuildRetry: true #type:string#修復數據時使用的目錄,默認是:A _tmp_repairDatabase_<num> directory under the dbPathrepairPath: #journal日志journal: #type:boolean#Enable or disable the durability journal to ensure data files remain valid and recoverable. Default: true on 64-bit systems, false on 32-bit systemsenabled: true #type:int#日志同步間隔,Values can range from 1 to 500 milliseconds.commitIntervalMs: 100 #type:boolean#是否開啟一數據庫一目錄,默認是falsedirectoryPerDB: false #type:int#數據落地時間間隔,默認為60秒,不能設置為0,一般使用默認值即可syncPeriodSecs: 60 #type:string##存儲引擎,默認wiredTiger,可選值 mmapv1,wiredTiger,inMemoryengine: wiredTiger#mmapv1存儲引擎配置 storage:mmapv1:#type:boolean#默認true,Enables or disables the preallocation of data files. preallocDataFiles: true#type:int#默認16M The default size for namespace files, which are files that end in .ns. nsSize: 16 #配額 quota: #type:boolean#是否強制限制每個數據庫數據文件數量限制,數量限制由maxFilesPerDB選項指定,默認為falseenforced: false #type:int#單個實例最大數據文件數量,需要先開啟enforced配置,默認8maxFilesPerDB: 8 #type:boolean#小文件存儲,默認為false,journal文件也會影響,適用場景:多數據庫且數據量不大smallFiles: false journal:#type:boolean#journal調試標志,用于測試功能,一般情況下不使用,系統異常關機會影響數據的完整性debugFlags: 0 #type:int#version >= 3.2版本不建議使用commitIntervalMs: 60 #wiredTiger存儲引擎配置 storage:wiredTiger:engineConfig:#type:float#單個實例可用的數據緩存內存大小,version >= 3.4默認:50% of RAM minus 1 GB, or 256 MB. Values can range from 256MB to 10TB and can be a float.cacheSizeGB: 0.25#type:string#WiredTiger journal數據壓縮格式,默認snappy,可用的壓縮類型: none, snappy, zlibjournalCompressor: snappy #type:boolean#索引文件分目錄存儲,默認false,version >= 3.0后版本可用directoryForIndexes: false collectionConfig:#type:string#塊數據壓縮格式,默認snappy,可用的壓縮類型:none, snappy, zlibblockCompressor: snappyindexConfig:#type:boolean#是否開啟索引prefix compression,默認trueprefixCompression: true #是否開啟索引prefix compression,默認true#operationProfiling操作性能分析 operationProfiling:#type:int#慢查詢時間單位毫秒,默認100,如果開啟了profile,日志會保存到system.profile集合中slowOpThresholdMs: 100 #type:string#性能分析模式,開啟會影響性能,謹慎操作。默認off.#可選值1:off: Off. No profiling.#可選值2: slowOp:On. Only includes slow operations.#可選值3: all:On. Includes all operations.mode: off#replication復制配置 replication:#type:int#數字類型(單位M) replication op log 大小,64位系統默認為可用磁盤的5%oplogSizeMB: 512#type:string#所屬replica set集群名稱replSetName: #type:string#The indexes that secondary members of a replica set load into memory before applying operations from the oplog. 默認all#可選值1 none:Secondaries do not load indexes into memory.#可選值2 all:Secondaries load all indexes related to an operation.#可選值3 _id_only:Secondaries load no additional indexes into memory beyond the already existing _id index.secondaryIndexPrefetch: all #type:boolean#默認false version >= 3.2版本可用 Enables read concern level of "majority".enableMajorityReadConcern:false #分片配置 sharding:#type:string#分片集群中的擔當的角色#可選值1 configsvr:配置svr#可選值2 shardsvr: 數據svrclusterRole: shardsvr#type:boolean#默認false#During chunk migration, a shard does not save documents migrated from the shard.archiveMovedChunks: false#auditLog配置 #僅企業版支付 auditLog:#type:string#審計日志保存方式#可選值1 syslog:Output the audit events to syslog in JSON format. #可選值2 console:Output the audit events to stdout in JSON format.#可選值3 file:Output the audit events to the file specified in --auditPath in the format specified in --auditFormat.destination: syslog#type:string#日志格式#可選值1:JSON#可選值2:BSONformat: JSON#type:string#日志文件路徑,相對路經和絕對路徑都支持path: path/audit.log#type:string representation of a document#The filter to limit the types of operations the audit system records.#內容格式:{ <field1>: <expression1>, ... }filter: {}#snmp(簡單網絡管理協議)配置 snmp:#type:boolean#When snmp.subagent is true, SNMP runs as a subagent. For more information, see Monitor MongoDB With SNMP on Linux.subagent:false#type:boolean#When snmp.master is true, SNMP runs as a master. For more information, see Monitor MongoDB With SNMP on Linux.master:false#Text Search配置 basisTech:#type:string#v3.2版本加入#僅企業版支持#Specify the path to the root directory of the Basis Technology Rosette Linguistics Platform installation to support additional languages for text search operations.rootDirectory:/path/#mongos-only Options replication:#type:integer#The ping time, in milliseconds, that mongos uses to determine which secondary replica set members to pass read operations from clients. #默認值為15毫秒localPingThresholdMs:15 sharding:#type:string#The configuration servers for the sharded cluster.#建議使用replica set#值格式:<configReplSetName>/cfg1.example.net:27017, cfg2.example.net:27017,...configDB:
參考文檔
【1】服務器配置文檔
https://docs.mongodb.com/manual/reference/configuration-options/
【2】服務器參數
https://docs.mongodb.com/manual/reference/parameters/
轉載于:https://www.cnblogs.com/wadeyu/p/7928496.html
總結
以上是生活随笔為你收集整理的mongodb之配置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 手动添加ubuntu服务
- 下一篇: [Leetcode Week13]Pal