-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
view-sharded-cluster-configuration.txt
108 lines (78 loc) · 3.72 KB
/
view-sharded-cluster-configuration.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
.. _sharding-manage-shards:
==========================
View Cluster Configuration
==========================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
.. _sharding-procedure-list-databases:
List Databases with Sharding Enabled
------------------------------------
To list the databases that have sharding enabled, query the
``databases`` collection in the :ref:`config-database`.
A database has sharding enabled if the value of the ``partitioned``
field is ``true``. Connect to a :binary:`~bin.mongos` instance with a
:binary:`~bin.mongo` shell, and run the following operation to get a full
list of databases with sharding enabled:
.. code-block:: javascript
use config
db.databases.find( { "partitioned": true } )
.. example:: You can use the following sequence of commands when to
return a list of all databases in the cluster:
.. code-block:: javascript
use config
db.databases.find()
If this returns the following result set:
.. code-block:: javascript
{ "_id" : "admin", "partitioned" : false, "primary" : "config" }
{ "_id" : "animals", "partitioned" : true, "primary" : "m0.example.net:30001" }
{ "_id" : "farms", "partitioned" : false, "primary" : "m1.example2.net:27017" }
Then sharding is only enabled for the ``animals`` database.
.. _sharding-procedure-list-shards:
List Shards
-----------
To list the current set of configured shards, use the :dbcommand:`listShards`
command, as follows:
.. code-block:: javascript
use admin
db.runCommand( { listShards : 1 } )
.. _sharding-procedure-view-clusters:
View Cluster Details
--------------------
To view cluster details, issue :method:`db.printShardingStatus()` or
:method:`sh.status()`. Both methods return the same output.
.. example:: In the following example output from :method:`sh.status()`
- ``sharding version`` displays the version number of the shard
metadata.
- ``shards`` displays a list of the :binary:`~bin.mongod` instances
used as shards in the cluster.
- ``databases`` displays all databases in the cluster,
including database that do not have sharding enabled.
- The ``chunks`` information for the ``foo`` database displays how
many chunks are on each shard and displays the range of each chunk.
.. code-block:: javascript
--- Sharding Status ---
sharding version: { "_id" : 1, "version" : 3 }
shards:
{ "_id" : "shard0000", "host" : "m0.example.net:30001" }
{ "_id" : "shard0001", "host" : "m3.example2.net:50000" }
databases:
{ "_id" : "admin", "partitioned" : false, "primary" : "config" }
{ "_id" : "contacts", "partitioned" : true, "primary" : "shard0000" }
foo.contacts
shard key: { "zip" : 1 }
chunks:
shard0001 2
shard0002 3
shard0000 2
{ "zip" : { "$minKey" : 1 } } -->> { "zip" : "56000" } on : shard0001 { "t" : 2, "i" : 0 }
{ "zip" : 56000 } -->> { "zip" : "56800" } on : shard0002 { "t" : 3, "i" : 4 }
{ "zip" : 56800 } -->> { "zip" : "57088" } on : shard0002 { "t" : 4, "i" : 2 }
{ "zip" : 57088 } -->> { "zip" : "57500" } on : shard0002 { "t" : 4, "i" : 3 }
{ "zip" : 57500 } -->> { "zip" : "58140" } on : shard0001 { "t" : 4, "i" : 0 }
{ "zip" : 58140 } -->> { "zip" : "59000" } on : shard0000 { "t" : 4, "i" : 1 }
{ "zip" : 59000 } -->> { "zip" : { "$maxKey" : 1 } } on : shard0000 { "t" : 3, "i" : 3 }
{ "_id" : "test", "partitioned" : false, "primary" : "shard0000" }