Windows
download MongoDB
mongodb 4.2
http://downloads.mongodb.org/win32/mongodb-win32-x86_64-2012plus-v4.2-latest.zip
download MongoDB for Windows directly from below:
http://dl.mongodb.org/dl/win32/x86_64
name | modified | size | md5 | sig | sha1 | sha256 |
---|---|---|---|---|---|---|
win32/mongodb-win32-x86_64-2012plus-debugsymbols-v4.2-latest.zip | 2020-04-17 19:13:58 | 243942504 | md5 | sig | sha1 | sha256 |
win32/mongodb-win32-x86_64-2012plus-v4.2-latest-signed.msi | 2020-04-17 19:13:48 | 277684736 | md5 | sha1 | sha256 |
(1)Install and start for windows
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/
Install MongoDB for Windows Manually Create a Windows Service for MongoDB Community Edition
(2) Configuration File Options
https://docs.mongodb.com/manual/reference/configuration-options/
Platform | Method | Configuration File |
---|---|---|
Linux | apt , yum , or zypper Package Manager | /etc/mongod.conf |
macOS | brew Package Manager |
|
Windows | MSI Installer | <install directory>\bin\mongod.cfg |
Windows:<install directory>/bin/mongod.conf
net: bindIp: 127.0.0.1
port: 27018
storage: dbPath: e:\mongodb\dataWiredTiger
journal:
enabled: true
wiredTiger:
engineConfig: cacheSizeGB: 1
(3) start
a.bat
title mongodb27018
f:
cd \mongodb\bin
mongod --config .\mongod.conf
一、mongodb 3.04 mongodb配置文件.conf (Linux)
配置文件在 /etc/mongod.conf文件里
启动方式 ./bin/mongod -f MongoDB.conf
会看到
about to fork child process, waiting until server is ready for connections.forked process: 2313child process started successfully, parent exiting
基本配置
#数据库数据存放目录
dbpath=/usr/local/mongodb304/data
#数据库日志存放目录
logpath=/usr/local/mongodb304/logs/mongodb.log
#以追加的方式记录日志
logappend = true
#端口号 默认为27017
port=27017
#以后台方式运行进程
fork=true
#开启用户认证
auth=true
#关闭http接口,默认关闭http端口访问
nohttpinterface=true
#mongodb所绑定的ip地址
bind_ip = 127.0.0.1
#启用日志文件,默认启用
journal=true
#这个选项可以过滤掉一些无用的日志信息,若需要调试使用请设置为false quiet=true
其他配置参数含义
--quiet # 安静输出
--port arg # 指定服务端口号,默认端口27017
--bind_ip arg # 绑定服务IP,若绑定127.0.0.1,则只能本机访问,不指定默认本地所有IP
--logpath arg # 指定MongoDB日志文件,注意是指定文件不是目录
--logappend # 使用追加的方式写日志
--pidfilepath arg # PID File 的完整路径,如果没有设置,则没有PID文件
--keyFile arg # 集群的私钥的完整路径,只对于Replica Set 架构有效
--unixSocketPrefix arg # UNIX域套接字替代目录,(默认为 /tmp)
--fork # 以守护进程的方式运行MongoDB,创建服务器进程
--auth # 启用验证
--cpu # 定期显示CPU的CPU利用率和iowait
--dbpath arg # 指定数据库路径
--diaglog arg # diaglog选项 0=off 1=W 2=R 3=both 7=W+some reads
--directoryperdb # 设置每个数据库将被保存在一个单独的目录
--journal # 启用日志选项,MongoDB的数据操作将会写入到journal文件夹的文件里
--journalOptions arg # 启用日志诊断选项
--ipv6 # 启用IPv6选项
--jsonp # 允许JSONP形式通过HTTP访问(有安全影响)
--maxConns arg # 最大同时连接数 默认2000
--noauth # 不启用验证
--nohttpinterface # 关闭http接口,默认关闭27018端口访问
--noprealloc # 禁用数据文件预分配(往往影响性能)
--noscripting # 禁用脚本引擎
--notablescan # 不允许表扫描
--nounixsocket # 禁用Unix套接字监听
--nssize arg (=16) # 设置信数据库.ns文件大小(MB)
--objcheck # 在收到客户数据,检查的有效性,
--profile arg # 档案参数 0=off 1=slow, 2=all --quota # 限制每个数据库的文件数,设置默认为8
--quotaFiles arg # number of files allower per db, requires --quota
--rest # 开启简单的rest API
--repair # 修复所有数据库run repair on all dbs
--repairpath arg # 修复库生成的文件的目录,默认为目录名称dbpath
--slowms arg (=100) # value of slow for profile and console log
--smallfiles # 使用较小的默认文件
--syncdelay arg (=60) # 数据写入磁盘的时间秒数(0=never,不推荐)
--sysinfo # 打印一些诊断系统信息
--upgrade # 如果需要升级数据库 * Replicaton 参数--------------------------------------------------------------------------------
--fastsync # 从一个dbpath里启用从库复制服务,该dbpath的数据库是主库的快照,可用于快速启用同步
--autoresync # 如果从库与主库同步数据差得多,自动重新同步,
--oplogSize arg # 设置oplog的大小(MB) * 主/从参数--------------------------------------------------------------------------------
--master # 主库模式 --slave # 从库模式
--source arg # 从库 端口号
--only arg # 指定单一的数据库复制
--slavedelay arg # 设置从库同步主库的延迟时间 * Replica set(副本集)选项:--------------------------------------------------------------------------------
--replSet arg # 设置副本集名称 * Sharding(分片)选项--------------------------------------------------------------------------------
--configsvr # 声明这是一个集群的config服务,默认端口27019,默认目录/data/configdb
--shardsvr # 声明这是一个集群的分片,默认端口27018
--noMoveParanoia # 关闭偏执为moveChunk数据保存 .