@@ -62,6 +62,7 @@ members of your replica set. For example, to shut down, use the
62
62
63
63
.. code-block:: sh
64
64
65
+ use admin
65
66
db.shutdownServer()
66
67
67
68
Restart this :program:`mongod` as a standalone instance
@@ -110,15 +111,20 @@ collection:
110
111
111
112
db.temp.drop()
112
113
113
- Use the :method:`db.collection.save()` method and a sort on
114
- reverse :term:`natural order` to find the last entry and save it
115
- to a temporary collection:
114
+ Retrieve the latest oplog entry by sorting on reverse :term:`natural order`.
115
+ Modify the entry to set ``op`` to "n" (representing a no-op) and clear the
116
+ ``o`` and ``o2`` fields. Then insert the modified oplog entry into a temporary
117
+ collection.
116
118
117
119
.. _last-oplog-entry:
118
120
119
121
.. code-block:: javascript
120
122
121
- db.temp.save( db.oplog.rs.find( { }, { ts: 1, h: 1 } ).sort( {$natural : -1} ).limit(1).next() )
123
+ var oplogEntry = db.oplog.rs.find().sort({$natural: -1}).limit(1).next();
124
+ oplogEntry.op = 'n'; // Change the entry to a no-op.
125
+ oplogEntry.o = {}; // Remove any update modifiers that would prevent saving the oplog entry to a normal collection.
126
+ oplogEntry.o2 = {};
127
+ db.temp.insert(oplogEntry);
122
128
123
129
To see this oplog entry, use the following operation:
124
130
@@ -159,12 +165,12 @@ Upon success, this command returns the following status:
159
165
Insert the Last Entry of the Old Oplog into the New Oplog
160
166
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
161
167
162
- Insert the previously saved last entry from the old oplog into the
163
- new oplog. For example:
168
+ Insert the previously inserted latest entry from the old oplog into the new
169
+ oplog. For example:
164
170
165
171
.. code-block:: javascript
166
172
167
- db.oplog.rs.save ( db.temp.findOne() )
173
+ db.oplog.rs.insert ( db.temp.findOne() )
168
174
169
175
To confirm the entry is in the new oplog, use the following operation:
170
176
0 commit comments