Skip to content

Fix pre-splitting / chunk-moving example #1249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions source/tutorial/manage-chunks-in-sharded-cluster.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ To create and migrate chunks manually, use the following procedure:
}
}

This assumes a collection size of 100 million documents.
This uses two-character prefixes to define split points, iterating with a "step size" of
six in the second position. So the first chunk would comprise e-mail addresses starting with
``aa`` through ``af``, the second ``ag`` through ``am``, etc.

#. Migrate chunks manually using the :dbcommand:`moveChunk` command:

Expand All @@ -156,11 +158,13 @@ To create and migrate chunks manually, use the following procedure:

.. code-block:: javascript

var shServer = [ "sh0.example.net", "sh1.example.net", "sh2.example.net", "sh3.example.net", "sh4.example.net" ];
var shServer = [ "sh0.example.net", "sh1.example.net", "sh2.example.net" ];
var curServer = 0;
for ( var x=97; x<97+26; x++ ){
for( var y=97; y<97+26; y+=6 ) {
var prefix = String.fromCharCode(x) + String.fromCharCode(y);
db.adminCommand({moveChunk : "myapp.users", find : {email : prefix}, to : shServer[(y-97)/6]})
db.adminCommand({moveChunk : "myapp.users", find : {email : prefix}, to : shServer[curServer]});
curServer = (curServer + 1) % shServer.length;
}
}

Expand Down