@@ -22,17 +22,14 @@ Definition
22
22
23
23
.. code-block:: javascript
24
24
25
- { replSetGetStatus: 1 }
25
+ db.adminCommand( { replSetGetStatus: 1 } )
26
26
27
27
The value specified does not affect the output of the command. Data
28
28
provided by this command derives from data included in heartbeats
29
29
sent to the server by other members of the replica set.
30
30
Because of the frequency of heartbeats, these data can be several
31
31
seconds out of date.
32
32
33
- You can also access this functionality through the
34
- :method:`rs.status()` helper in the :binary:`~bin.mongo` shell.
35
-
36
33
The :binary:`~bin.mongod` instance must have replication enabled and be a
37
34
member of a replica set for :dbcommand:`replSetGetStatus` to return
38
35
successfully.
@@ -42,125 +39,257 @@ Definition
42
39
Example
43
40
-------
44
41
45
- The following example runs the :command:`replSetGetStatus` command on the
46
- :term:`admin database` of the replica set primary:
47
-
48
- .. code-block:: javascript
49
-
50
- db.adminCommand( { replSetGetStatus : 1 } )
51
-
52
- Consider the following example output:
53
-
54
- .. code-block:: javascript
55
-
56
- {
57
- "set" : "replset",
58
- "date" : ISODate("2018-11-09T19:57:21.099Z"),
59
- "myState" : 1,
60
- "term" : NumberLong(1),
61
- "syncingTo" : "",
62
- "syncSourceHost" : "",
63
- "syncSourceId" : -1,
64
- "heartbeatIntervalMillis" : NumberLong(2000),
65
- "optimes" : {
66
- "lastCommittedOpTime" : {
67
- "ts" : Timestamp(1541793436, 1),
68
- "t" : NumberLong(1)
69
- },
70
- "readConcernMajorityOpTime" : {
71
- "ts" : Timestamp(1541793436, 1),
72
- "t" : NumberLong(1)
73
- },
74
- "appliedOpTime" : {
75
- "ts" : Timestamp(1541793436, 1),
76
- "t" : NumberLong(1)
77
- },
78
- "durableOpTime" : {
79
- "ts" : Timestamp(1541793436, 1),
80
- "t" : NumberLong(1)
81
- }
82
- },
83
- "members" : [
84
- {
85
- "_id" : 0,
86
- "name" : "m1.example.net:27017",
87
- "health" : 1,
88
- "state" : 1,
89
- "stateStr" : "PRIMARY",
90
- "uptime" : 269,
91
- "optime" : {
92
- "ts" : Timestamp(1541793436, 1),
93
- "t" : NumberLong(1)
94
- },
95
- "optimeDate" : ISODate("2018-11-09T19:57:16Z"),
96
- "syncingTo" : "",
97
- "syncSourceHost" : "",
98
- "syncSourceId" : -1,
99
- "infoMessage" : "could not find member to sync from",
100
- "electionTime" : Timestamp(1541795054, 1),
101
- "electionDate" : ISODate("2018-11-09T20:24:14Z"),
102
- "configVersion" : 1,
103
- "self" : true
104
- "lastHeartbeatMessage" : ""
105
-
106
- },
107
- {
108
- "_id" : 1,
109
- "name" : "m2.example.net:27017",
110
- "health" : 1,
111
- "state" : 2,
112
- "stateStr" : "SECONDARY",
113
- "uptime" : 14,
114
- "optime" : {
115
- "ts" : Timestamp(1541793436, 1),
116
- "t" : NumberLong(1)
117
- },
118
- "optimeDurable" : {
119
- "ts" : Timestamp(1541793436, 1),
120
- "t" : NumberLong(1)
121
- },
122
- "optimeDate" : ISODate("2018-11-09T19:57:16Z"),
123
- "optimeDurableDate" : ISODate("2018-11-09T19:57:16Z"),
124
- "lastHeartbeat" : ISODate("2018-11-09T19:57:19.228Z"),
125
- "lastHeartbeatRecv" : ISODate("2018-11-09T19:57:19.526Z"),
126
- "pingMs" : NumberLong(0),
127
- "lastHeartbeatMessage" : "",
128
- "syncingTo" : "m1.example.net:27017",
129
- "syncSourceHost" : "m1.example.net:27017",
130
- "syncSourceId" : 0,
131
- "infoMessage" : "",
132
- "configVersion" : 1
133
- },
134
- {
135
- "_id" : 2,
136
- "name" : "m3.example.net:27017",
137
- "health" : 1,
138
- "state" : 2,
139
- "stateStr" : "SECONDARY",
140
- "uptime" : 14,
141
- "optime" : {
142
- "ts" : Timestamp(1541793436, 1),
143
- "t" : NumberLong(1)
144
- },
145
- "optimeDurable" : {
146
- "ts" : Timestamp(1541793436, 1),
147
- "t" : NumberLong(1)
148
- },
149
- "optimeDate" : ISODate("2018-11-09T19:57:16Z"),
150
- "optimeDurableDate" : ISODate("2018-11-09T19:57:16Z"),
151
- "lastHeartbeat" : ISODate("2018-11-09T19:57:19.228Z"),
152
- "lastHeartbeatRecv" : ISODate("2018-11-09T19:57:19.526Z"),
153
- "pingMs" : NumberLong(0),
154
- "lastHeartbeatMessage" : "",
155
- "syncingTo" : "m1.example.net:27017",
156
- "syncSourceHost" : "m1.example.net:27017",
157
- "syncSourceId" : 0,
158
- "infoMessage" : "",
159
- "configVersion" : 1
160
- }
161
- ],
162
- "ok" : 1
163
- }
42
+ .. tabs::
43
+
44
+ tabs:
45
+
46
+ - id: primary
47
+ name: Primary
48
+ content: |
49
+
50
+ The following example runs the :dbcommand:`replSetGetStatus`
51
+ command on the :term:`admin database` of the replica set
52
+ primary:
53
+
54
+ .. code-block:: javascript
55
+
56
+ db.adminCommand( { replSetGetStatus : 1 } )
57
+
58
+ The command returns the following output for an example replica set primary:
59
+
60
+ .. code-block:: javascript
61
+
62
+ {
63
+ "set" : "replset",
64
+ "date" : ISODate("2018-12-06T16:57:52.480Z"),
65
+ "myState" : 1,
66
+ "term" : NumberLong(1),
67
+ "syncingTo" : "",
68
+ "syncSourceHost" : "",
69
+ "syncSourceId" : -1,
70
+ "heartbeatIntervalMillis" : NumberLong(2000),
71
+ "optimes" : {
72
+ "lastCommittedOpTime" : {
73
+ "ts" : Timestamp(1544115471, 2),
74
+ "t" : NumberLong(1)
75
+ },
76
+ "readConcernMajorityOpTime" : {
77
+ "ts" : Timestamp(1544115471, 2),
78
+ "t" : NumberLong(1)
79
+ },
80
+ "appliedOpTime" : {
81
+ "ts" : Timestamp(1544115471, 2),
82
+ "t" : NumberLong(1)
83
+ },
84
+ "durableOpTime" : {
85
+ "ts" : Timestamp(1544115471, 2),
86
+ "t" : NumberLong(1)
87
+ }
88
+ },
89
+ "members" : [
90
+ {
91
+ "_id" : 0,
92
+ "name" : "m1.example.net:27017",
93
+ "health" : 1,
94
+ "state" : 1,
95
+ "stateStr" : "PRIMARY",
96
+ "uptime" : 123,
97
+ "optime" : {
98
+ "ts" : Timestamp(1544115471, 2),
99
+ "t" : NumberLong(1)
100
+ },
101
+ "optimeDate" : ISODate("2018-12-06T16:57:51Z"),
102
+ "syncingTo" : "",
103
+ "syncSourceHost" : "",
104
+ "syncSourceId" : -1,
105
+ "infoMessage" : "could not find member to sync from",
106
+ "electionTime" : Timestamp(1544115363, 1),
107
+ "electionDate" : ISODate("2018-12-06T16:56:03Z"),
108
+ "configVersion" : 1,
109
+ "self" : true,
110
+ "lastHeartbeatMessage" : ""
111
+ },
112
+ {
113
+ "_id" : 1,
114
+ "name" : "m2.example.net:27017",
115
+ "health" : 1,
116
+ "state" : 2,
117
+ "stateStr" : "SECONDARY",
118
+ "uptime" : 120,
119
+ "optime" : {
120
+ "ts" : Timestamp(1544115471, 2),
121
+ "t" : NumberLong(1)
122
+ },
123
+ "optimeDurable" : {
124
+ "ts" : Timestamp(1544115471, 2),
125
+ "t" : NumberLong(1)
126
+ },
127
+ "optimeDate" : ISODate("2018-12-06T16:57:51Z"),
128
+ "optimeDurableDate" : ISODate("2018-12-06T16:57:51Z"),
129
+ "lastHeartbeat" : ISODate("2018-12-06T16:57:51.963Z"),
130
+ "lastHeartbeatRecv" : ISODate("2018-12-06T16:57:52.082Z"),
131
+ "pingMs" : NumberLong(0),
132
+ "lastHeartbeatMessage" : "",
133
+ "syncingTo" : "m1.example.net:27017",
134
+ "syncSourceHost" : "m1.example.net:27017",
135
+ "syncSourceId" : 0,
136
+ "infoMessage" : "",
137
+ "configVersion" : 1
138
+ },
139
+ {
140
+ "_id" : 2,
141
+ "name" : "m3.example.net:27017",
142
+ "health" : 1,
143
+ "state" : 2,
144
+ "stateStr" : "SECONDARY",
145
+ "uptime" : 120,
146
+ "optime" : {
147
+ "ts" : Timestamp(1544115471, 2),
148
+ "t" : NumberLong(1)
149
+ },
150
+ "optimeDurable" : {
151
+ "ts" : Timestamp(1544115471, 2),
152
+ "t" : NumberLong(1)
153
+ },
154
+ "optimeDate" : ISODate("2018-12-06T16:57:51Z"),
155
+ "optimeDurableDate" : ISODate("2018-12-06T16:57:51Z"),
156
+ "lastHeartbeat" : ISODate("2018-12-06T16:57:51.963Z"),
157
+ "lastHeartbeatRecv" : ISODate("2018-12-06T16:57:52.082Z"),
158
+ "pingMs" : NumberLong(0),
159
+ "lastHeartbeatMessage" : "",
160
+ "syncingTo" : "m1.example.net:27017",
161
+ "syncSourceHost" : "m1.example.net:27017",
162
+ "syncSourceId" : 0,
163
+ "infoMessage" : "",
164
+ "configVersion" : 1
165
+ }
166
+ ],
167
+ "ok" : 1
168
+ }
169
+
170
+ - id: secondary
171
+ name: Secondary
172
+ content: |
173
+
174
+ The following example runs the :dbcommand:`replSetGetStatus`
175
+ command on the :term:`admin database` of the replica set
176
+ primary.
177
+
178
+ .. code-block:: javascript
179
+
180
+ db.adminCommand( { replSetGetStatus : 1 } )
181
+
182
+ The command returns the following output for an example replica set secondary:
183
+
184
+ .. code-block:: javascript
185
+
186
+ {
187
+ "set" : "replset",
188
+ "date" : ISODate("2018-12-06T17:03:43.222Z"),
189
+ "myState" : 2,
190
+ "term" : NumberLong(1),
191
+ "syncingTo" : "m1.example.net:27017",
192
+ "syncSourceHost" : "m1.example.net:27017",
193
+ "syncSourceId" : 0,
194
+ "heartbeatIntervalMillis" : NumberLong(2000),
195
+ "optimes" : {
196
+ "lastCommittedOpTime" : {
197
+ "ts" : Timestamp(1544115815, 1),
198
+ "t" : NumberLong(1)
199
+ },
200
+ "readConcernMajorityOpTime" : {
201
+ "ts" : Timestamp(1544115815, 1),
202
+ "t" : NumberLong(1)
203
+ },
204
+ "appliedOpTime" : {
205
+ "ts" : Timestamp(1544115815, 1),
206
+ "t" : NumberLong(1)
207
+ },
208
+ "durableOpTime" : {
209
+ "ts" : Timestamp(1544115815, 1),
210
+ "t" : NumberLong(1)
211
+ }
212
+ },
213
+ "members" : [
214
+ {
215
+ "_id" : 0,
216
+ "name" : "m1.example.net:27017",
217
+ "health" : 1,
218
+ "state" : 1,
219
+ "stateStr" : "PRIMARY",
220
+ "uptime" : 468,
221
+ "optime" : {
222
+ "ts" : Timestamp(1544115815, 1),
223
+ "t" : NumberLong(1)
224
+ },
225
+ "optimeDurable" : {
226
+ "ts" : Timestamp(1544115815, 1),
227
+ "t" : NumberLong(1)
228
+ },
229
+ "optimeDate" : ISODate("2018-12-06T17:03:35Z"),
230
+ "optimeDurableDate" : ISODate("2018-12-06T17:03:35Z"),
231
+ "lastHeartbeat" : ISODate("2018-12-06T17:03:42.506Z"),
232
+ "lastHeartbeatRecv" : ISODate("2018-12-06T17:03:42.414Z"),
233
+ "pingMs" : NumberLong(0),
234
+ "lastHeartbeatMessage" : "",
235
+ "syncingTo" : "",
236
+ "syncSourceHost" : "",
237
+ "syncSourceId" : -1,
238
+ "infoMessage" : "",
239
+ "electionTime" : Timestamp(1544115363, 1),
240
+ "electionDate" : ISODate("2018-12-06T16:56:03Z"),
241
+ "configVersion" : 1
242
+ },
243
+ {
244
+ "_id" : 1,
245
+ "name" : "m2.example.net:27017",
246
+ "health" : 1,
247
+ "state" : 2,
248
+ "stateStr" : "SECONDARY",
249
+ "uptime" : 473,
250
+ "optime" : {
251
+ "ts" : Timestamp(1544115815, 1),
252
+ "t" : NumberLong(1)
253
+ },
254
+ "optimeDate" : ISODate("2018-12-06T17:03:35Z"),
255
+ "syncingTo" : "m1.example.net:27017",
256
+ "syncSourceHost" : "m1.example.net:27017",
257
+ "syncSourceId" : 0,
258
+ "infoMessage" : "",
259
+ "configVersion" : 1,
260
+ "self" : true,
261
+ "lastHeartbeatMessage" : ""
262
+ },
263
+ {
264
+ "_id" : 2,
265
+ "name" : "m3.example.net:27017",
266
+ "health" : 1,
267
+ "state" : 2,
268
+ "stateStr" : "SECONDARY",
269
+ "uptime" : 468,
270
+ "optime" : {
271
+ "ts" : Timestamp(1544115815, 1),
272
+ "t" : NumberLong(1)
273
+ },
274
+ "optimeDurable" : {
275
+ "ts" : Timestamp(1544115815, 1),
276
+ "t" : NumberLong(1)
277
+ },
278
+ "optimeDate" : ISODate("2018-12-06T17:03:35Z"),
279
+ "optimeDurableDate" : ISODate("2018-12-06T17:03:35Z"),
280
+ "lastHeartbeat" : ISODate("2018-12-06T17:03:42.506Z"),
281
+ "lastHeartbeatRecv" : ISODate("2018-12-06T17:03:42.500Z"),
282
+ "pingMs" : NumberLong(0),
283
+ "lastHeartbeatMessage" : "",
284
+ "syncingTo" : "m1.example.net:27017",
285
+ "syncSourceHost" : "m1.example.net:27017",
286
+ "syncSourceId" : 0,
287
+ "infoMessage" : "",
288
+ "configVersion" : 1
289
+ }
290
+ ],
291
+ "ok" : 1
292
+ }
164
293
165
294
Output
166
295
------
0 commit comments