[英]Sharding & Replication in mongodb
First of all, I'm a beginner in mongoDB so please be patient with me. 首先,我是mongoDB的初学者,所以请耐心等待。 I'm using windows and I created a simple database that contains 4 collections.
我正在使用Windows,并创建了一个包含4个集合的简单数据库。 When I'm dealing with mongoDB, I first run:
mongod.exe --dbpath "Path To Data Folder"
in a terminal and then I connect to the mongod using mongo.exe
. 当我处理mongoDB时,我首先运行:
mongod.exe --dbpath "Path To Data Folder"
在终端中mongod.exe --dbpath "Path To Data Folder"
,然后使用mongo.exe
连接到mongod。 What I'm supposed to do is to distribute the database along with its collections into shards and replica sets for supporting distributed queries. 我应该做的就是将数据库及其集合分发到分片和副本集中,以支持分布式查询。
I tried to use commands like sh.enableSharding("DATABASE NAME")
but it didn't work. 我尝试使用
sh.enableSharding("DATABASE NAME")
类的命令,但是没有用。 I then figured out that I need to run mongos instead of mongod, so I followed this: Sharding in MongoDB but unfortunately I didn't succeeded. 然后,我发现我需要运行mongos而不是mongod,所以我遵循了这一点: 在MongoDB中进行分片,但不幸的是,我没有成功。 I also did some research but it seems there is a lack of to-the-point guides on sharding and replication.
我也做了一些研究,但是似乎缺乏关于分片和复制的重点指南。 So if you point me to the right direction, I would really appreciate it.
因此,如果您指出正确的方向,我将非常感激。
You can't enable sharding on a single database instance. 您不能在单个数据库实例上启用分片。 You need to have at least 3 config server instances, two database (mongod) instances and a router instance (mongos).
您至少需要3个配置服务器实例,两个数据库(mongod)实例和一个路由器实例(mongos)。 All of them should be running in the same time (ie don't close the terminals in which you started all your instances).
所有这些都应该在同一时间运行(即,不要关闭启动所有实例的终端)。
A good starting point for you is to read the sharding tutorial in Deploy a Sharded Cluster - MongoDB.org 一个不错的起点是阅读“ 部署分片集群”中的分片教程-MongoDB.org
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.