4
4
ref : connect-mongos
5
5
---
6
6
title :
7
- text : Enable sharding for a database.
8
- character : " `"
9
- stepnum : 2
10
- ref : enable-sharding-db-level
11
- pre : |
12
- Before you can shard a collection, you must first enable sharding
13
- for the collection's database. Enabling sharding for a database does not
14
- redistribute data but makes it possible to shard the collections in
15
- that database.
16
- action :
17
- - pre : |
18
- The following operation enables
19
- sharding on the ``test`` database:
20
- language: sh
21
- code: |
22
- sh.enableSharding( "test" )
23
- - pre : |
24
- .. include:: /includes/extracts/mongos-operations-wc-enable-sharding.rst
25
-
26
- The operation returns the status of the operation:
27
- language: sh
28
- code: |
29
- { "ok" : 1 }
30
- ---
31
- title :
32
7
text : Determine the shard key.
33
8
character : " `"
34
- stepnum : 3
9
+ stepnum : 2
35
10
ref : determine-shard-key
36
11
content : |
37
12
For the collection to shard, determine the shard key. The :ref:`shard
@@ -45,14 +20,14 @@ content: |
45
20
- allow for effective distribution of activity among shards.
46
21
47
22
For more information, see :ref:`sharding-shard-key-selection`.
48
-
23
+
49
24
This procedure will use the ``number`` field as the shard key for
50
25
``test_collection``.
51
26
---
52
- title :
27
+ title :
53
28
text : Create an index on the shard key.
54
29
character : " `"
55
- stepnum : 4
30
+ stepnum : 3
56
31
ref : enable-sharding-create-index
57
32
pre : |
58
33
Before sharding a non-empty collection, create an :doc:`index on
@@ -63,10 +38,10 @@ action:
63
38
use test
64
39
db.test_collection.createIndex( { number : 1 } )
65
40
---
66
- title :
41
+ title :
67
42
text : Shard the collection.
68
43
character : " `"
69
- stepnum : 5
44
+ stepnum : 4
70
45
ref : enable-sharding-collection
71
46
action :
72
47
- pre : |
@@ -77,7 +52,7 @@ action:
77
52
use test
78
53
sh.shardCollection( "test.test_collection", { "number" : 1 } )
79
54
- pre : |
80
-
55
+
81
56
.. include:: /includes/extracts/mongos-operations-wc-shard-collection.rst
82
57
83
58
The method returns the status of the operation:
@@ -93,7 +68,7 @@ post: |
93
68
title :
94
69
text : Confirm the shard is balancing.
95
70
character : " `"
96
- stepnum : 6
71
+ stepnum : 5
97
72
ref : enable-sharding-confirm
98
73
action :
99
74
- pre : |
0 commit comments