赞
踩
- cd /opt
- wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.4.0.tgz
- tar -zxvf mongodb-linux-x86_64-3.4.0.tgz
-
- #修改文件夹名字为mongodb-3.4.0
- mv mongodb-linux-x86_64-3.4.0 mongodb-3.4.0
-
- # 在/opt/mongodb-3.4.0/conf目录下创建mongo.conf
- # 内容如下------------------
-
- # 存储引擎相关参数
- storage:
- dbPath: /opt/mongodb-3.4.0/data/mongodb
- journal:
- enabled: true
- mmapv1:
- smallFiles: true
- engine: wiredTiger
- # 如下配置仅对 wiredTiger 引擎生效(3.0 以上版本)
- wiredTiger:
- engineConfig:
- configString: cache_size=1G
- cacheSizeGB: 5
-
- # 进程相关参数
- processManagement:
- fork: true
- # 日志相关参数
- systemLog:
- destination: file
- logAppend: true
- path: /opt/mongodb-3.4.0/logs/mongodb.log
-
- # 网络相关参数
- net:
- # 这个端口改成其它的就是无法连接,不知道为啥,还是使用默认的
- port: 27017
- bindIp: 0.0.0.0
- maxIncomingConnections: 10000
-
- # 自定义变量
- setParameter:
- enableLocalhostAuthBypass: false
- # 安全相关参数,先启动去配置用户不要打开下面的配置。
- #security:
- # authorization: enabled
-
-
- # 启动脚本
- /opt/mongodb-3.4.0/bin/mongod --config=/opt/mongodb-3.4.0/conf/mongo.conf
-
-
- # 创建用户
- /opt/mongodb-3.4.0/bin/mongo
- # 数据库
- use admin
-
- db.createUser({user: "mongoadmin", pwd: "mongoAdmin@1116", roles: [ { role: "root", db: "admin" } ]})
-
- db.auth('mongoadmin','mongoAdmin@1116')
-
- exit
- # 然后去修改配置文件,把下面的放开,然后用navicat去连接,使用刚才的账号就可以连接了
- # 安全相关参数,先启动去配置用户不要打开下面的配置。
- security:
- authorization: enabled
-
- # 然后linux放开端口
- # linux添加8080端口
- firewall-cmd --zone=public --add-port=8080/tcp --permanent
- #删除80端口
- firewall-cmd --zone=public --remove-port=8080/tcp --permanent
- # 刷新使端口立即生效
- firewall-cmd --reload
-
- # 阿里云放开端口
注意yml从第二季开始是2个空格为一个层级,不是tab。
- systemLog:
- verbosity: <int> #日志级别,默认0,1-5均会包含debug信息
- quiet: <bool> #安静,true时将会减少日志的输出量
- traceAllExceptions: <bool> #打印异常详细信息
- syslogFacility: <string> #启用syslog指定用于登录时信息到syslog Facility水平,前提是
- path: <string> #日志路径
- logAppend: <bool> #追加日志还是新建日志
- logRotate: rename|reopen #日志轮询。默认值rename;reopen前提为 logAppend: true
- destination: <string> #日志输出目的地,可为file或syslog,不指定会输出到标准输出
- timeStampFormat: <string> #日志时间戳格式,有 ctime,Iso869-utc,iso8691-local
- component: #为不同的组件指定各自的日志信息级别
- accessControl:
- verbosity: <int>
- command:
- verbosity: <int>
- storage:
- dbPath: <string> #数据存储目录
- indexBuildRetry: <bool> #构件索引时mongod意外关闭,启动是否重建索引,默认true
- repairPath: <string> #在repair期间临时数据目录
- journal:
- enabled: <boolean> #journal日志是否持久存储,通常用于数据故障恢复,建议开启
- commitIntervalMs: <num> #mongod日志刷新值,范围1-500毫秒,默认100,不建议修改
- directoryPerDB: <bool> #是否将不同的数据存储在不同的目录中,需为dbPath子目录
- syncPeriodSecs: <int> #fsync操作将数据flush到磁盘的时间间隔,默认为60秒,不建议修改
- engine: <string> #存储引擎类型,3.2前默认 mmapv1,3.2后默认WiredTiger
- wiredTiger: #存储引擎配置
- engineConfig:
- cacheSizeGB: <number> #最大缓存大小
- journalCompressor: <string> #日志压缩算法,可选值有 none,snappy(默认),zlib
- directoryForIndexes: <bool> #是否将索引和集合数据分别存储在dbPath单独的目录中
- collectionConfig:
- blockCompressor: <string> #collection数据压缩算法,可选none, snappy,zlib
- indexConfig:
- prefixCompression: <bool> #是否对索引数据使用前缀压缩。可有效减少索引数据的内存使用量。
- processManagement:
- fork: <boolean> #是否以守护进程运行,默认false
- pidFilePath: <string> #将mongod进程ID写入指定文件,默认不会创建
- net:
- prot: <int> #监听端口,默认27017
- bindIp: <string> #绑定IP,如果此值是“0.0.0.0”则绑定所有接口
- maxIncomingConnections: <int> #进程允许的最大连接数,上限是系统阈值(ulimit)
- wireObjectCheck: <boolean> #当客户端写入数据时,是否检查数据的有效性(BSON),有效的数据才执行
- ipv6: <bool> #是否支持多实例之间使用ipv6
- http: #http配置
- enabled: <boolean>
- JSONEnabled: <boolean>
- RESTInterfaceEnabled: <boolean>
- ssl: #https配置
- sslOnNormalPorts: <boolean>
- mode: <string>
- PEMKeyFile: <string>
- PEMKeyPassword: <string>
- clusterFile: <string>
- clusterPassword: <string>
- CAFile: <string>
- CRLFile: <string>
- allowConnectionsWithoutCertificates: <boolean>
- allowInvalidCertificates: <boolean>
- allowInvalidHostnames: <boolean>
- disabledProtocols: <string>
- FIPSMode: <boolean>
- compression:
- compressors: <string>
- security:
- authorization: enabled #MondoDB认证功能
- keyFile: /path/mongo.key #MongoDB副本集节点身份验证密钥文件
- clusterAuthMode: <string> #集群members间的认证模式
- transitionToAuth: <boolean>
- javascriptEnabled: <boolean> #是否允许执行JavaScript脚本
- redactClientLogData: <boolean>
- sasl:
- hostName: <string>
- serviceName: <string>
- saslauthdSocketPath: <string>
- enableEncryption: <boolean>
- encryptionCipherMode: <string>
- encryptionKeyFile: <string>
- kmip:
- keyIdentifier: <string>
- rotateMasterKey: <boolean>
- serverName: <string>
- port: <string>
- clientCertificateFile: <string>
- clientCertificatePassword: <string>
- serverCAFile: <string>
- ldap:
- servers: <string>
- bind:
- method: <string>
- saslMechanism: <string>
- queryUser: <string>
- queryPassword: <string>
- useOSDefaults: <boolean>
- transportSecurity: <string>
- timeoutMS: <int>
- userToDNMapping: <string>
- authz:
- queryTemplate: <string>
- operationProfiling:
- slowOpThresholdMs: <int> #“慢查询”的时间阈值,单位毫秒(默认100ms)
- mode: <string> #数据库profiler级别,可选值“off|slowOp|all”
- # 数据库profiling会影响性能,建议只在性能调试阶段开启,mongod会把慢查询记录到日志中
- replication:
- oplogSizeMB: <int> #replication操作日志的最大尺寸,如果太小则全量同步
- replSetName: <string> #副本集名称,副本集中所有的mongod实例都必须有相同的名字
- secondaryIndexPrefetch: <string> #副本集中的secondary,从oplog中应用变更操作前,会先把索引加载到内存
- enalbeMajorityReadConcern: <boolean> #允许readConcern的级别为“majority”
- sharding:
- clusterRole: <string> #在sharding集群中的角色。configsvr(27019)|shardsvr(27018)
- archiveMovedChunks: <bool> #当chunks迁移后,是否归档并保存这些chunks在dbPath/movechunk目录下
- setParameter:
- <parameter1>: <value1>
- <parameter2>: <value2>
- enableLocalhostAuthBypass: false #栗子
- auditLog:
- destination: <string> #指定审计记录的输出方式,有syslog|console|file
- format: <string> #输出格式,有JSON 和 BSON
- path: <string> #如果输入为文件,那么指定文件完整路径及文件名
- filter: <string> #过滤器,可限制审计系统记录的操作类型
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。