本地搭建MongoDB Server
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/
- Overview
- Requirements
- Get MongoDB Community Edition
- Install MongoDB Community Edition
- Run MongoDB Community Edition
- Configure a Windows Service for MongoDB Community Edition
- Manually Create a Windows Service for MongoDB Community Edition
- Additional Resources
概览
系统要求
获取社区版
下载社区版本的https://www.mongodb.com/download-center#community
安装社区版
直接使用msi进行安装,安装安装后,将C:\Program Files\MongoDB\Server\3.4\bin配置到环境变量的PATH中
然后打开Command Prompt,输入
C:\Windows\System32>mongod --version
db version v3.4.2
git version: 3f76e40c105fc223b3e5aac3e20dcd026b83b38b
OpenSSL version: OpenSSL 1.0.1u-fips 22 Sep 2016
allocator: tcmalloc
modules: none
build environment:
distmod: 2008plus-ssl
distarch: x86_64
target_arch: x86_64
运行社区版
警告:
Do not make mongod.exe
visible on public networks without running in “Secure Mode” with the auth
setting.
MongoDB is designed to be run in trusted environments, and the database does not enable “Secure Mode” by default.
Set up the MongoDB environment.
MongoDB requires a data directory to store all data.
MongoDB’s default data directory path is the absolute path \data\db
on the drive from which you start MongoDB.
Create this folder by running the following command in a Command Prompt:
You can specify an alternate path for data files using the --dbpath
option to mongod.exe
, for example:
"C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe" --dbpath d:\test\mongodb\data
If your path includes spaces, enclose the entire path in double quotes, for example:
"C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe" --dbpath "d:\test\mongo db data"
You may also specify the dbpath
in a configuration file.
通过命令直接配置F:\DataBase\MongoDB>mongod --dbpath .
本人使用的是3.4版本的,这个命令直接会触发了启动
F:\DataBase\MongoDB>mongod --dbpath .
2017-02-28T15:45:07.212+0800 I CONTROL [initandlisten] MongoDB starting : pid=7
884 port=27017 dbpath=. 64-bit host=ChuckLu
2017-02-28T15:45:07.215+0800 I CONTROL [initandlisten] targetMinOS: Windows 7/W
indows Server 2008 R2
2017-02-28T15:45:07.216+0800 I CONTROL [initandlisten] db version v3.4.2
2017-02-28T15:45:07.217+0800 I CONTROL [initandlisten] git version: 3f76e40c105
fc223b3e5aac3e20dcd026b83b38b
2017-02-28T15:45:07.218+0800 I CONTROL [initandlisten] OpenSSL version: OpenSSL
1.0.1u-fips 22 Sep 2016
2017-02-28T15:45:07.219+0800 I CONTROL [initandlisten] allocator: tcmalloc
2017-02-28T15:45:07.220+0800 I CONTROL [initandlisten] modules: none
2017-02-28T15:45:07.221+0800 I CONTROL [initandlisten] build environment:
2017-02-28T15:45:07.221+0800 I CONTROL [initandlisten] distmod: 2008plus-ss
l
2017-02-28T15:45:07.222+0800 I CONTROL [initandlisten] distarch: x86_64
2017-02-28T15:45:07.223+0800 I CONTROL [initandlisten] target_arch: x86_64
2017-02-28T15:45:07.225+0800 I CONTROL [initandlisten] options: { storage: { db
Path: "." } }
2017-02-28T15:45:07.249+0800 I STORAGE [initandlisten] wiredtiger_open config:
create,cache_size=5590M,session_max=20000,eviction=(threads_max=4),config_base=f
alse,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=sn
appy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),st
atistics_log=(wait=0),
2017-02-28T15:45:07.953+0800 I CONTROL [initandlisten]
2017-02-28T15:45:07.953+0800 I CONTROL [initandlisten] ** WARNING: Access contr
ol is not enabled for the database.
2017-02-28T15:45:07.955+0800 I CONTROL [initandlisten] ** Read and wri
te access to data and configuration is unrestricted.
2017-02-28T15:45:07.956+0800 I CONTROL [initandlisten]
2017-02-28T15:45:07.957+0800 I CONTROL [initandlisten] Hotfix KB2731284 or late
r update is not installed, will zero-out data files.
2017-02-28T15:45:07.960+0800 I CONTROL [initandlisten]
2017-02-28T15:45:09.805+0800 I FTDC [initandlisten] Initializing full-time d
iagnostic data capture with directory './diagnostic.data'
2017-02-28T15:45:10.050+0800 I INDEX [initandlisten] build index on: admin.sy
stem.version properties: { v: 2, key: { version: 1 }, name: "incompatible_with_v
ersion_32", ns: "admin.system.version" }
2017-02-28T15:45:10.051+0800 I INDEX [initandlisten] building index
using bulk method; build may temporarily use up to 500 megabytes of RAM
2017-02-28T15:45:10.065+0800 I INDEX [initandlisten] build index done. scann
ed 0 total records. 0 secs
2017-02-28T15:45:10.067+0800 I COMMAND [initandlisten] setting featureCompatibi
lityVersion to 3.4
2017-02-28T15:45:10.069+0800 I NETWORK [thread1] waiting for connections on por
t 27017
Start MongoDB
To start MongoDB, run mongod.exe
. For example, from the Command Prompt:
"C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe"
This starts the main MongoDB database process. The waiting for connections
message in the console output indicates that the mongod.exe
process is running successfully.
Depending on the security level of your system, Windows may pop up a Security Alert dialog box about blocking “some features” of C:\ProgramFiles\MongoDB\Server\3.4\bin\mongod.exe
from communicating on networks.
All users should select Private Networks, such as my home or work network
and click Allowaccess
. For additional information on security and MongoDB, please see the Security Documentation.
Connect to MongoDB.
重新打开一个命令行窗口,打开mongo.exe
To connect to MongoDB through the mongo.exe
shell, open another Command Prompt.
"C:\Program Files\MongoDB\Server\3.4\bin\mongo.exe
客户端连接上之后,通过exit进行退出
If you want to develop applications using .NET, see the documentation of C# and MongoDB for more information.
C:\Program Files\MongoDB\Server\3.4\bin>mongo.exe
MongoDB shell version v3.4.2
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.2
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
http://docs.mongodb.org/
Questions? Try the support group
http://groups.google.com/group/mongodb-user
Server has startup warnings:
2017-02-28T15:45:07.953+0800 I CONTROL [initandlisten]
2017-02-28T15:45:07.953+0800 I CONTROL [initandlisten] ** WARNING: Access contr
ol is not enabled for the database.
2017-02-28T15:45:07.955+0800 I CONTROL [initandlisten] ** Read and wri
te access to data and configuration is unrestricted.
2017-02-28T15:45:07.956+0800 I CONTROL [initandlisten]
2017-02-28T15:45:07.957+0800 I CONTROL [initandlisten] Hotfix KB2731284 or late
r update is not installed, will zero-out data files.
2017-02-28T15:45:07.960+0800 I CONTROL [initandlisten]
Begin using MongoDB.
To help you start using MongoDB, MongoDB provides Getting Started Guides in various driver editions. See Getting Started for the available editions.
Before deploying MongoDB in a production environment, consider the Production Notes document.
Later, to stop MongoDB, press Control+C
in the terminal where the mongod
instance is running.
Configure a Windows Service for MongoDB Community Edition
Open an Administrator command prompt.
Press the Win
key, type cmd.exe
, and press Ctrl + Shift + Enter
to run the Command Prompt as Administrator.
Execute the remaining steps from the Administrator command prompt.
Create directories.
Create directories for your database and log files:
mkdir c:\data\db
mkdir c:\data\log
Create a configuration file
Create a configuration file. The file must set systemLog.path
. Include additional configuration options as appropriate.
C:\Program Files\MongoDB\Server\3.4>type nul>mongod.cfg 生成一个cfg文件,然后用notepad++编辑
For example, create a file at C:\Program Files\MongoDB\Server\3.4\mongod.cfg
that specifies both systemLog.path
and storage.dbPath
:
systemLog:
destination: file
path: c:\data\log\mongod.log
storage:
dbPath: c:\data\db
Install the MongoDB service.
Run all of the following commands in Command Prompt with “Administrative Privileges”.
Install the MongoDB service by starting mongod.exe
with the --install
option and the -config
option to specify the previously created configuration file.
"C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe" --config "C:\Program Files\MongoDB\Server\3.4\mongod.cfg" --install
To use an alternate dbpath
, specify the path in the configuration file (e.g.C:\mongodb\mongod.cfg
) or on the command line with the --dbpath
option.
If needed, you can install services for multiple instances of mongod.exe
or mongos.exe
.
Install each service with a unique --serviceName
and --serviceDisplayName
.
Use multiple instances only when sufficient足够的 system resources exist and your system design requires it.
F:\DataBase\MongoDB\test>mongod --config "c:\Program Files\MongoDB\Server\3.4\mongod.cfg" --install
Start the MongoDB service.
net start MongoDB
Stop or remove the MongoDB service as needed.
net stop MongoDB
To remove the MongoDB service use the following command:
"C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe" --remove
本地搭建MongoDB Server的更多相关文章
- IntelliJ IDEA 、PyCharm、WebStorm、PhpStorm等JetBrains公司软件 激活的License Server本地搭建教程
一.背景 IntelliJ IDEA是JetBrains公司的一款IDE,主要用于java开发,可以编写Java.Groovy.Kotlin.Scala等语言,也可以直接做Android开发. 同系列 ...
- 搭建带热更新功能的本地开发node server
引言 使用webpack有一段时间了,对其中的热更新的大概理解是:对某个模块做了修改,页面只做局部更新而不需要刷新整个页面来进行更新.这样就能节省因为整个页面刷新所产生开销的时间,模块热加载加快了开发 ...
- phpstorm破解 IntelliJ IDEA License Server本地搭建教程 http://blog.lanyus.com/archives/174.html/comment-page-6#comments 附件:mac环境
ilanyu's Blog 搜索关键字搜索 首页IDEA注册码文件中转在线记事本老博客关于 IntelliJ IDEA License Server本地搭建教程 作者: ilanyu 时间: Marc ...
- 在centos7上搭建mongodb副本集
1.安装副本集介绍 副本集(Replica Set)是一组MongoDB实例组成的集群,由一个主(Primary)服务器和多个备份(Secondary)服务器构成.通过Replication,将数据的 ...
- windows2012服务器搭建mongodb并设置远程访问
因为python脚本需要用到mongodb,而且需要本地查看数据库,所以就在腾讯云的windows服务器上部署了mongodb服务器,因为网上大部分教程是针对linux的自己搜索走了很多坑,这里记录下 ...
- 从0开始搭建SQL Server AlwaysOn 第一篇(配置域控)
从0开始搭建SQL Server AlwaysOn 第一篇(配置域控) 第一篇http://www.cnblogs.com/lyhabc/p/4678330.html第二篇http://www.cnb ...
- 从0开始搭建SQL Server AlwaysOn 第三篇(配置AlwaysOn)
从0开始搭建SQL Server AlwaysOn 第三篇(配置AlwaysOn) 第一篇http://www.cnblogs.com/lyhabc/p/4678330.html第二篇http://w ...
- 从0开始搭建SQL Server AlwaysOn 第四篇(配置异地机房节点)
从0开始搭建SQL Server AlwaysOn 第四篇(配置异地机房节点) 第一篇http://www.cnblogs.com/lyhabc/p/4678330.html第二篇http://www ...
- (转) 从0开始搭建SQL Server AlwaysOn 第三篇(配置AlwaysOn)
原文地址: http://www.cnblogs.com/lyhabc/p/4682986.html 这一篇是从0开始搭建SQL Server AlwaysOn 的第三篇,这一篇才真正开始搭建Alwa ...
随机推荐
- 海尔公布首套智能套装SmartCare,主打智能、简单
2014CIE智能硬件首发会于11月6-8日在上海国际展览中心举行.吸引了海尔.英特尔.百度等知名企业的积极參与. 作为国内智能家居领域的先驱者,海尔在本次大会上首发了轻量智能套装SmartC ...
- c++变量的作用域、生存期和可见性
局部变量 范围:在一个函数内部定义的变量,作用范围仅仅限于本函数体内. 生存期:程序运行到本函数才会给局部变量分配内存单元.函数运行完成局部变量所占的存储单元就被释放 全局变量 在函数体外部定义的变量 ...
- 省赛i题/求1~n内全部数对(x,y),满足最大公约数是质数的对数
求1~n内全部数对(x,y),gcd(x,y)=质数,的对数. 思路:用f[n]求出,含n的对数.最后用sum[n]求和. 对于gcd(x,y)=a(设x<=y,a是质数),则必有gcd(x/a ...
- nyoj--27--水池数目(dfs)
水池数目 时间限制:3000 ms | 内存限制:65535 KB 难度:4 描述 南阳理工学院校园里有一些小河和一些湖泊,现在,我们把它们通一看成水池,假设有一张我们学校的某处的地图,这个地图上 ...
- oracle 11g RAC 的一些基本概念
一.脑裂以及对策 脑裂(split-brain)是集群中的一个糟糕的情况:集群中的所有集群正在工作的时候,内部通讯被断开.这种情况下,集群被分成了几个部分,每个部分的集群软件都会尝试去接管其他节点的资 ...
- Scalable, Distributed Systems Using Akka, Spring Boot, DDD, and Java--转
原文地址:https://dzone.com/articles/scalable-distributed-systems-using-akka-spring-boot-ddd-and-java Whe ...
- Codeforces 987B. High School: Become Human
解题思路: 1.题意:判断x^y和y^x谁大谁小. 2.由于x^y和y^x太大了,时间复杂度也不允许,所以做同等变换,比较e^(ylnx)和e^(xlny). 3.即为比较ylnx和xlny的大小. ...
- DataView和DefaultView的理解
DefaultView 的作用(对DataSet查询出的来数据进行排序)(这个老哥的太长了) DefaultView:默认视图.datatable.DefaultView获取整个表的视图(就像sql查 ...
- spline interpolation and draw image by matplotlib
1 # spline interpolation and draw image by matplotlib from scipy import interpolate import matplotli ...
- STM8S103之ADC
如何快速了解ADC,查看Reference manual中ADC registers章节,初步了解到ADC ADC buffer register和ADC data register Analog W ...