Windows install MongoDB .zip green version

Green version (.zip): https://fastdl.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-3.6.11.zip

Installation version (the .msi): https://fastdl.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-3.6.11-signed.msi

 Personal preferences "Soft" installation, its portability, the system of identification is strong, "means a zip world" ^ _ ^. Windows, Linux, Mac systems all recognize the .zip file. After the disk path may change, simply modify the system path environment variable path, you can resume normal use. It applies to persons familiar with the system environment.

Note: After MongoDB 2.2 version is no longer supported by Windows XP system. The latest version also has no installation files 32-bit systems.


1.  Custom Installation (decompression) to:

D:\Program Files\mongodb-win32-x86_64-2008plus-ssl-3.6.11
  
  

2. Configure the system environment variable path:

3. Create folders and files in the installation path:

  1. "/data" 和 "/log" 两个文件夹("/data"文件夹下,用于存放数据库源数据;"/log"文件夹下,用于存放logger日志);
  2. 在data文件夹下创建"/db"空文件夹
  3. 在log文件夹下创建"mongo.log"空文件

注:其实data和log两个文件夹,在何处创建都无所谓,依个人习惯。关键在于下一步骤,"mongo.config"配置内容中,"dbpath"和"logpath"所指向的路径。

为将重要文件与非重要文件分离,以便数据移植,故data文件夹与log文件夹分开创建。

4. 在安装路径下创建配置文件“mongo.config”,并写入以下内容:


   
   
  1. #数据库文件的存放位置
  2. dbpath=D:\Program Files\mongodb-win32-x86_64- 2008plus-ssl- 3.6. 11\data\db
  3. #日志文件存放的路径
  4. logpath=D:\Program Files\mongodb-win32-x86_64- 2008plus-ssl- 3.6. 11\ log\mongo.log

 

5. 以“超级管理员身份”运行"cmd",创建MongoDB管理服务,输入以下命令:

mongod --config "D:\Program Files\mongodb-win32-x86_64-2008plus-ssl-3.6.11\mongo.config" --install --serviceName "MongoDB"

  
  

 

 启动MongoDB服务命令(同样要使用“超级管理员身份运行”):

net start MongoDB

   
   

关闭MongoDB服务命令:

net stop MongoDB

   
   

 

 6. 启动服务完成后,win + R直接运行"cmd",输入"mongo"即可运行。

显示信息如下:

C:\Users\PC>mongo
MongoDB shell version v3.6.11
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.6.11
Server has startup warnings:
2019-03-13T15:36:39.950+0800 I CONTROL  [initandlisten]
2019-03-13T15:36:39.950+0800 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2019-03-13T15:36:39.950+0800 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2019-03-13T15:36:39.950+0800 I CONTROL  [initandlisten]
2019-03-13T15:36:39.950+0800 I CONTROL  [initandlisten] ** WARNING: This server is bound to localhost.
2019-03-13T15:36:39.950+0800 I CONTROL  [initandlisten] **          Remote systems will be unable to connect to this server.
2019-03-13T15:36:39.950+0800 I CONTROL  [initandlisten] **          Start the server with --bind_ip <address> to specify which IP
2019-03-13T15:36:39.950+0800 I CONTROL  [initandlisten] **          addresses it should serve responses from, or with --bind_ip_all to
2019-03-13T15:36:39.950+0800 I CONTROL  [initandlisten] **          bind to all interfaces. If this behavior is desired, start the
2019-03-13T15:36:39.950+0800 I CONTROL  [initandlisten] **          server with --bind_ip 127.0.0.1 to disable this warning.
2019-03-13T15:36:39.950+0800 I CONTROL  [initandlisten]
>


mongo.config文件详解


   
   
  1. # 端口号,默认27017
  2. #port=27017
  3. # 数据库文件位置
  4. dbpath=/data/db
  5. #日志文件位置
  6. logpath=/log/mongo.log
  7. # 是否追加方式写入日志,默认True
  8. logappend= true
  9. # 设置绑定ip
  10. bind_ip = 127.0 .0 .1
  11. # 设置端口
  12. port = 27017
  13. # 是否以守护进程方式运行,默认false
  14. fork = true
  15. #这个选项可以过滤掉一些无用的日志信息,若需要调试使用请设置为false
  16. quiet= false
  17. # 启用日志文件,默认启用
  18. journal= true
  19. # 启用定期记录CPU利用率和 I/O 等待,默认false
  20. #cpu = true
  21. # 是否以安全认证方式运行,默认是不认证的非安全方式
  22. #noauth = true
  23. #auth = true
  24. # 详细记录输出,默认false
  25. #verbose = true
  26. #用于开发驱动程序时验证客户端请求
  27. #objcheck = true
  28. # # 启用数据库配额管理,默认false
  29. #quota = true
  30. # 设置oplog日志记录等级,默认0
  31. # 0=off (default)
  32. # 1=W
  33. # 2=R
  34. # 3=both
  35. # 7=W+some reads
  36. #oplog = 0
  37. # 是否打开动态调试项,默认false
  38. #nocursors = true
  39. # 忽略查询提示,默认false
  40. #nohints = true
  41. # 禁用http界面,默认为localhost:28017
  42. #nohttpinterface = true
  43. # 关闭服务器端脚本,这将极大的限制功能,默认false
  44. #noscripting = true
  45. # 关闭扫描表,任何查询将会是扫描失败
  46. #notablescan = true
  47. # 关闭数据文件预分配
  48. #noprealloc = true
  49. # 为新数据库指定.ns文件的大小,单位:MB
  50. # nssize = <size>
  51. # 用于Mongo监控服务器的Accout token。
  52. #mms-token = <token>
  53. # Mongo监控服务器的服务器名称。
  54. #mms-name = <server-name>
  55. # Mongo监控服务器的Ping间隔时间,即心跳
  56. #mms-interval = <seconds>
  57. # Replication Options
  58. # 设置主从复制参数
  59. #slave = true # 设置从节点
  60. #source = master.example.com # 指定从节点的主节点
  61. # Slave only: 指定要复制的单个数据库
  62. #only = master.example.com
  63. # or
  64. #master = true # 设置主节点
  65. #source = slave.example.com
  66. # 设置副本集的名字,所有的实例指定相同的名字属于一个副本集
  67. replSet = name
  68. #pairwith = <server:port>
  69. # 仲裁服务器地址
  70. #arbiter = <server:port>
  71. # 默认为false,用于从实例设置。是否自动重新同步
  72. #autoresync = true
  73. # 指定的复制操作日志(OPLOG)的最大大小
  74. #oplogSize = <MB>
  75. # 限制复制操作的内存使用
  76. #opIdMem = <bytes>
  77. # 设置ssl认证
  78. # Enable SSL on normal ports
  79. #sslOnNormalPorts = true
  80. # SSL Key file and password
  81. #sslPEMKeyFile = /etc/ssl/mongodb.pem
  82. #sslPEMKeyPassword = pass
  83. # path to a key file storing authentication info for connections
  84. # between replica set members
  85. #指定存储身份验证信息的密钥文件的路径
  86. #keyFile=/path/to/keyfile

MongoDB集群基本配置:


   
   
  1. # 集群配置文件
  2. dbpath=/ var/lib/mongodb
  3. logpath=/ var/log/mongodb/mongodb.log
  4. pidfilepath=/ var/log/mongodb/master.pid
  5. directoryperdb= true
  6. logappend= true
  7. replSet=name
  8. bind_ip= 127.0 .0 .1
  9. port= 27017
  10. fork= true
  11. noprealloc= true
原文地址:https://blog.csdn.net/HTouying/article/details/88428452

 

Guess you like

Origin www.cnblogs.com/jpfss/p/11247703.html