At present, many tutorials on the internet talk about MongoDB sharding configuration, but most of them have not gone through practical practices and are reproduced randomly. In addition, the different configurations of MongoDB versions are messy, making the users confused.
Recently I have also made MongoDB sharding and pasted my configuration. In addition, let's talk to everyone about the issues that need attention. I hope you can correct them if they are inappropriate. We also hope that later users can bypass these problems.
To ensure data security, the formal environment must be backed up. For details about multipart copy, see alibaba Tutorial:
The cluster I configured is used for testing and has not been copied. It is just a simple test of multipart storage data. During the test, it is difficult to split and copy multiple machines. Many examples on the Internet are incorrect, so it took me a lot of time.
The structure after configuration is complete is:
My Mongo version is: mongodb-linux-x86_64-2.0.8, the computer is normal Pc.
Here I would like to note:
1. In Big Data scenarios, it is best to use a 64-bit machine. A 32-bit machine cannot create a single file larger than 2 GB. Small Data size does not matter
2. The system of each computer in the cluster should be the same. Do not use 32-bit or 64-bit pairs.
-- This is what I did when I started the test. There are 2 sets of 64, 2 sets of 32. when the data of about million data is injected and the index is greater than 3-4 GB, a 32-bit machine error occurs. A single file larger than 2 GB cannot be created on a 32-bit system. The whole cluster is paralyzed. I have been looking for reasons for this for a long time.
Let's get started!
The unzipped mongo directory structure is as follows: the installation directory is $ {MONGO_INSTALL}
Run the following commands on $ {cmd_install} on the first computer:
Mkdir-p/data/shard11
Bin/mongod-shardsvr-port 27017-dbpath =/data/shard11/-logpath =/data/shard11.log -- fork