<section>
 <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium">
  Replica Set Secondary Members
  <a class="headerlink leafygreen-ui-1kepx47" href="#replica-set-secondary-members" title="Permalink to this heading">
   <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
    <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
    </path>
    <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
    </path>
   </svg>
   <div class="css-1btu0w3 evvkmar0" id="replica-set-secondary-members">
   </div>
  </a>
 </h1>
 <p class="leafygreen-ui-1kp3ins">
  A secondary maintains a copy of the
  <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-primary">
   primary's
  </a>
  data
set. To replicate data, a secondary applies operations from the
primary's
  <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-oplog/#std-label-replica-set-oplog">
   oplog
  </a>
  to its own data set
in an asynchronous process.
  <a class="footnote-reference header-buffer" href="#footnote-slow-oplogs" id="ref-slow-oplogs-id1">
   [
   <!-- -->
   1
   <!-- -->
   ]
  </a>
  A replica set can have one or more
secondaries.
 </p>
 <p class="leafygreen-ui-1kp3ins">
  The following three-member replica set has two secondary
members. The secondaries replicate the primary's oplog and apply
the operations to their data sets.
 </p>
 <div class="figure css-5vkxs0" style="width:700px">
  <img alt="Diagram of a 3 member replica set that consists of a primary and two secondaries." class="leafygreen-ui-1qnf57e" height="280" src="/docs/manual/images/replica-set-primary-with-two-secondaries.bakedsvg.svg" style="--border-color:#C1C7C6" width="740"/>
 </div>
 <p class="leafygreen-ui-1kp3ins">
  Although clients cannot write data to secondaries, clients can read
data from secondary members. See
  <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/read-preference/">
   Read Preference
  </a>
  for more
information on how clients direct read operations to replica sets.
 </p>
 <p class="leafygreen-ui-1kp3ins">
  A secondary can become a primary.
If the current primary becomes unavailable, the replica set
holds an
  <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-election">
   election
  </a>
  to choose which of the secondaries
becomes the new primary.
 </p>
 <p class="leafygreen-ui-1kp3ins">
  In the following three-member replica set, the primary becomes unavailable.
This triggers an election where one of the remaining
secondaries becomes the new primary.
 </p>
 <div class="css-18h91be ej97su30">
  <div role="button" tabindex="-1">
   <img alt="Diagram of an election of a new primary. In a three member replica set with two secondaries, the primary becomes unreachable. The loss of a primary triggers an election where one of the secondaries becomes the new primary" class="leafygreen-ui-1qnf57e" height="500" src="/docs/manual/images/replica-set-trigger-election.bakedsvg.svg" style="--border-color:#C1C7C6" width="660"/>
   <div class="css-19pi7x2 ej97su31" style="--color:#444">
    click to enlarge
   </div>
  </div>
 </div>
 <p class="leafygreen-ui-1kp3ins">
  See
  <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-elections/">
   Replica Set Elections
  </a>
  for more details.
 </p>
 <p class="leafygreen-ui-1kp3ins">
  You can configure a secondary member for a specific purpose. You can
configure a secondary to:
 </p>
 <ul class="leafygreen-ui-rioki0">
  <li class="leafygreen-ui-d7p7b6">
   <p class="leafygreen-ui-1kp3ins">
    Prevent it from becoming a primary in an election, which allows it to
reside in a secondary data center or to serve as a cold standby. See
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-priority-0-member/">
     Priority 0 Replica Set Members
     <!-- -->
     .
    </a>
   </p>
  </li>
  <li class="leafygreen-ui-d7p7b6">
   <p class="leafygreen-ui-1kp3ins">
    Prevent applications from reading from it, which allows it to run applications
that require separation from normal traffic. See
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-hidden-member/">
     Hidden Replica Set Members
     <!-- -->
     .
    </a>
   </p>
  </li>
  <li class="leafygreen-ui-d7p7b6">
   <p class="leafygreen-ui-1kp3ins">
    Keep a running "historical" snapshot for use in recovery from
certain errors, such as unintentionally deleted databases. See
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-delayed-member/">
     Delayed Replica Set Members
     <!-- -->
     .
    </a>
   </p>
  </li>
 </ul>
 <table class="header-buffer leafygreen-ui-rbqgrl" frame="void" id="footnote-slow-oplogs" rules="none">
  <colgroup>
   <col/>
  </colgroup>
  <tbody valign="top">
   <tr>
    <td class="leafygreen-ui-17r2xs0">
     [
     <a href="#ref-slow-oplogs-id1">
      1
     </a>
     ]
    </td>
    <td class="leafygreen-ui-17r2xs0">
     <!-- -->
     Secondary members of a replica set now
     <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-oplog/#std-label-slow-oplog-application">
      log oplog entries
     </a>
     that take longer than the slow operation
threshold to apply. These slow oplog messages:
     <ul class="leafygreen-ui-rioki0">
      <li class="leafygreen-ui-d7p7b6">
       Are logged for the secondaries in the
       <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#std-option-mongod.--logpath">
        <code class="leafygreen-ui-1l06pbn">
         diagnostic log
        </code>
        .
       </a>
      </li>
      <li class="leafygreen-ui-d7p7b6">
       Are logged under the
       <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/log-messages/#mongodb-data-REPL">
        <code class="leafygreen-ui-1l06pbn">
         REPL
        </code>
       </a>
       component with the text
       <code class="leafygreen-ui-1l06pbn">
        applied op: &lt;oplog entry&gt; took &lt;num&gt;ms
       </code>
       .
      </li>
      <li class="leafygreen-ui-d7p7b6">
       Do not depend on the log levels (either at the system or component
level)
      </li>
      <li class="leafygreen-ui-d7p7b6">
       Do not depend on the profiling level.
      </li>
      <li class="leafygreen-ui-d7p7b6">
       Are affected by
       <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-operationProfiling.slowOpSampleRate">
        <code class="leafygreen-ui-1l06pbn">
         slowOpSampleRate
        </code>
        .
       </a>
      </li>
     </ul>
     The profiler does not capture slow oplog entries.
    </td>
   </tr>
  </tbody>
 </table>
</section>
