<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="mysql-cluster-config-starting">
      </a>
      25.4.3.2 Recommended Starting Configuration for NDB Cluster
     </h4>
    </div>
   </div>
  </div>
  <p>
   Achieving the best performance from an NDB Cluster depends on a
        number of factors including the following:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      NDB Cluster software version
     </p>
    </li>
    <li class="listitem">
     <p>
      Numbers of data nodes and SQL nodes
     </p>
    </li>
    <li class="listitem">
     <p>
      Hardware
     </p>
    </li>
    <li class="listitem">
     <p>
      Operating system
     </p>
    </li>
    <li class="listitem">
     <p>
      Amount of data to be stored
     </p>
    </li>
    <li class="listitem">
     <p>
      Size and type of load under which the cluster is to operate
     </p>
    </li>
   </ul>
  </div>
  <p>
   Therefore, obtaining an optimum configuration is likely to be an
        iterative process, the outcome of which can vary widely with the
        specifics of each NDB Cluster deployment. Changes in
        configuration are also likely to be indicated when changes are
        made in the platform on which the cluster is run, or in
        applications that use the NDB Cluster 's data. For these
        reasons, it is not possible to offer a single configuration that
        is ideal for all usage scenarios. However, in this section, we
        provide a recommended base configuration.
  </p>
  <p>
   <b>
    Starting config.ini file.
   </b>
   The following
   <code class="filename">
    config.ini
   </code>
   file is a
          recommended starting point for configuring a cluster running
          NDB Cluster 8.4:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa56045213"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token comment" spellcheck="true"># TCP PARAMETERS</span>

<span class="token selector">[tcp default]</span>
<span class="token constant">SendBufferMemory</span><span class="token attr-value"><span class="token punctuation">=</span>2M</span>
<span class="token constant">ReceiveBufferMemory</span><span class="token attr-value"><span class="token punctuation">=</span>2M</span>

<span class="token comment" spellcheck="true"># Increasing the sizes of these 2 buffers beyond the default values</span>
<span class="token comment" spellcheck="true"># helps prevent bottlenecks due to slow disk I/O.</span>

<span class="token comment" spellcheck="true"># MANAGEMENT NODE PARAMETERS</span>

<span class="token selector">[ndb_mgmd default]</span>
<span class="token constant">DataDir</span><span class="token attr-value"><span class="token punctuation">=</span><em class="replaceable">path/to/management/server/data/directory</em></span>

<span class="token comment" spellcheck="true"># It is possible to use a different data directory for each management</span>
<span class="token comment" spellcheck="true"># server, but for ease of administration it is preferable to be</span>
<span class="token comment" spellcheck="true"># consistent.</span>

<span class="token selector">[ndb_mgmd]</span>
<span class="token constant">HostName</span><span class="token attr-value"><span class="token punctuation">=</span><em class="replaceable">management-server-A-hostname</em></span>
<span class="token comment" spellcheck="true"># NodeId=<em class="replaceable">management-server-A-nodeid</em></span>

<span class="token selector">[ndb_mgmd]</span>
<span class="token constant">HostName</span><span class="token attr-value"><span class="token punctuation">=</span><em class="replaceable">management-server-B-hostname</em></span>
<span class="token comment" spellcheck="true"># NodeId=<em class="replaceable">management-server-B-nodeid</em></span>

<span class="token comment" spellcheck="true"># Using 2 management servers helps guarantee that there is always an</span>
<span class="token comment" spellcheck="true"># arbitrator in the event of network partitioning, and so is</span>
<span class="token comment" spellcheck="true"># recommended for high availability. Each management server must be</span>
<span class="token comment" spellcheck="true"># identified by a HostName. You may for the sake of convenience specify</span>
<span class="token comment" spellcheck="true"># a NodeId for any management server, although one is allocated</span>
<span class="token comment" spellcheck="true"># for it automatically; if you do so, it must be in the range 1-255</span>
<span class="token comment" spellcheck="true"># inclusive and must be unique among all IDs specified for cluster</span>
<span class="token comment" spellcheck="true"># nodes.</span>

<span class="token comment" spellcheck="true"># DATA NODE PARAMETERS</span>

<span class="token selector">[ndbd default]</span>
<span class="token constant">NoOfReplicas</span><span class="token attr-value"><span class="token punctuation">=</span>2</span>

<span class="token comment" spellcheck="true"># Using two fragment replicas is recommended to guarantee availability of data;</span>
<span class="token comment" spellcheck="true"># using only one fragment replica does not provide any redundancy, which means</span>
<span class="token comment" spellcheck="true"># that the failure of a single data node causes the entire cluster to shut down. </span>
<span class="token comment" spellcheck="true"># It is also possible (but not required) to use more than two fragment replicas, </span>
<span class="token comment" spellcheck="true"># although two fragment replicas are sufficient to provide high availability. </span>

<span class="token constant">LockPagesInMainMemory</span><span class="token attr-value"><span class="token punctuation">=</span>1</span>

<span class="token comment" spellcheck="true"># On Linux and Solaris systems, setting this parameter locks data node</span>
<span class="token comment" spellcheck="true"># processes into memory. Doing so prevents them from swapping to disk,</span>
<span class="token comment" spellcheck="true"># which can severely degrade cluster performance.</span>

<span class="token constant">DataMemory</span><span class="token attr-value"><span class="token punctuation">=</span>3456M</span>

<span class="token comment" spellcheck="true"># The value provided for DataMemory assumes 4 GB RAM</span>
<span class="token comment" spellcheck="true"># per data node. However, for best results, you should first calculate</span>
<span class="token comment" spellcheck="true"># the memory that would be used based on the data you actually plan to</span>
<span class="token comment" spellcheck="true"># store (you may find the ndb_size.pl utility helpful in estimating</span>
<span class="token comment" spellcheck="true"># this), then allow an extra 20% over the calculated values. Naturally,</span>
<span class="token comment" spellcheck="true"># you should ensure that each data node host has at least as much</span>
<span class="token comment" spellcheck="true"># physical memory as the sum of these two values.</span>

<span class="token comment" spellcheck="true"># ODirect=1</span>

<span class="token comment" spellcheck="true"># Enabling this parameter causes NDBCLUSTER to try using O_DIRECT</span>
<span class="token comment" spellcheck="true"># writes for local checkpoints and redo logs; this can reduce load on</span>
<span class="token comment" spellcheck="true"># CPUs. We recommend doing so when using NDB Cluster on systems running</span>
<span class="token comment" spellcheck="true"># Linux kernel 2.6 or later.</span>

<span class="token constant">NoOfFragmentLogFiles</span><span class="token attr-value"><span class="token punctuation">=</span>300</span>
<span class="token constant">DataDir</span><span class="token attr-value"><span class="token punctuation">=</span><em class="replaceable">path/to/data/node/data/directory</em></span>
<span class="token constant">MaxNoOfConcurrentOperations</span><span class="token attr-value"><span class="token punctuation">=</span>100000</span>

<span class="token constant">SchedulerSpinTimer</span><span class="token attr-value"><span class="token punctuation">=</span>400</span>
<span class="token constant">SchedulerExecutionTimer</span><span class="token attr-value"><span class="token punctuation">=</span>100</span>
<span class="token constant">RealTimeScheduler</span><span class="token attr-value"><span class="token punctuation">=</span>1</span>
<span class="token comment" spellcheck="true"># Setting these parameters allows you to take advantage of real-time scheduling</span>
<span class="token comment" spellcheck="true"># of NDB threads to achieve increased throughput when using ndbd. They</span>
<span class="token comment" spellcheck="true"># are not needed when using ndbmtd; in particular, you should not set</span>
<span class="token comment" spellcheck="true"># RealTimeScheduler for ndbmtd data nodes.</span>

<span class="token constant">TimeBetweenGlobalCheckpoints</span><span class="token attr-value"><span class="token punctuation">=</span>1000</span>
<span class="token constant">TimeBetweenEpochs</span><span class="token attr-value"><span class="token punctuation">=</span>200</span>
<span class="token constant">RedoBuffer</span><span class="token attr-value"><span class="token punctuation">=</span>32M</span>

<span class="token comment" spellcheck="true"># CompressedLCP=1</span>
<span class="token comment" spellcheck="true"># CompressedBackup=1</span>
<span class="token comment" spellcheck="true"># Enabling CompressedLCP and CompressedBackup causes, respectively, local</span>
checkpoint files and backup files to be compressed, which can result in a space
savings of up to 50% over noncompressed LCPs and backups.

<span class="token comment" spellcheck="true"># MaxNoOfLocalScans=64</span>
<span class="token constant">MaxNoOfTables</span><span class="token attr-value"><span class="token punctuation">=</span>1024</span>
<span class="token constant">MaxNoOfOrderedIndexes</span><span class="token attr-value"><span class="token punctuation">=</span>256</span>

<span class="token selector">[ndbd]</span>
<span class="token constant">HostName</span><span class="token attr-value"><span class="token punctuation">=</span><em class="replaceable">data-node-A-hostname</em></span>
<span class="token comment" spellcheck="true"># NodeId=<em class="replaceable">data-node-A-nodeid</em></span>

<span class="token constant">LockExecuteThreadToCPU</span><span class="token attr-value"><span class="token punctuation">=</span>1</span>
<span class="token constant">LockMaintThreadsToCPU</span><span class="token attr-value"><span class="token punctuation">=</span>0</span>
<span class="token comment" spellcheck="true"># On systems with multiple CPUs, these parameters can be used to lock NDBCLUSTER</span>
<span class="token comment" spellcheck="true"># threads to specific CPUs</span>

<span class="token selector">[ndbd]</span>
<span class="token constant">HostName</span><span class="token attr-value"><span class="token punctuation">=</span><em class="replaceable">data-node-B-hostname</em></span>
<span class="token comment" spellcheck="true"># NodeId=<em class="replaceable">data-node-B-nodeid</em></span>

<span class="token constant">LockExecuteThreadToCPU</span><span class="token attr-value"><span class="token punctuation">=</span>1</span>
<span class="token constant">LockMaintThreadsToCPU</span><span class="token attr-value"><span class="token punctuation">=</span>0</span>

<span class="token comment" spellcheck="true"># You must have an [ndbd] section for every data node in the cluster;</span>
<span class="token comment" spellcheck="true"># each of these sections must include a HostName. Each section may</span>
<span class="token comment" spellcheck="true"># optionally include a NodeId for convenience, but in most cases, it is</span>
<span class="token comment" spellcheck="true"># sufficient to allow the cluster to allocate node IDs dynamically. If</span>
<span class="token comment" spellcheck="true"># you do specify the node ID for a data node, it must be in the range 1</span>
<span class="token comment" spellcheck="true"># to 144 inclusive and must be unique among all IDs specified for</span>
<span class="token comment" spellcheck="true"># cluster nodes.</span>

<span class="token comment" spellcheck="true"># SQL NODE / API NODE PARAMETERS</span>

<span class="token selector">[mysqld]</span>
<span class="token comment" spellcheck="true"># HostName=<em class="replaceable">sql-node-A-hostname</em></span>
<span class="token comment" spellcheck="true"># NodeId=<em class="replaceable">sql-node-A-nodeid</em></span>

<span class="token selector">[mysqld]</span>

<span class="token selector">[mysqld]</span>

<span class="token comment" spellcheck="true"># Each API or SQL node that connects to the cluster requires a [mysqld]</span>
<span class="token comment" spellcheck="true"># or [api] section of its own. Each such section defines a connection</span>
<span class="token comment" spellcheck="true"># “slot”; you should have at least as many of these sections in the</span>
<span class="token comment" spellcheck="true"># config.ini file as the total number of API nodes and SQL nodes that</span>
<span class="token comment" spellcheck="true"># you wish to have connected to the cluster at any given time. There is</span>
<span class="token comment" spellcheck="true"># no performance or other penalty for having extra slots available in</span>
<span class="token comment" spellcheck="true"># case you find later that you want or need more API or SQL nodes to</span>
<span class="token comment" spellcheck="true"># connect to the cluster at the same time.</span>
<span class="token comment" spellcheck="true"># If no HostName is specified for a given [mysqld] or [api] section,</span>
<span class="token comment" spellcheck="true"># then <em>any</em> API or SQL node may use that slot to connect to the</span>
<span class="token comment" spellcheck="true"># cluster. You may wish to use an explicit HostName for one connection slot</span>
<span class="token comment" spellcheck="true"># to guarantee that an API or SQL node from that host can always</span>
<span class="token comment" spellcheck="true"># connect to the cluster. If you wish to prevent API or SQL nodes from</span>
<span class="token comment" spellcheck="true"># connecting from other than a desired host or hosts, then use a</span>
<span class="token comment" spellcheck="true"># HostName for every [mysqld] or [api] section in the config.ini file.</span>
<span class="token comment" spellcheck="true"># You can if you wish define a node ID (NodeId parameter) for any API or</span>
<span class="token comment" spellcheck="true"># SQL node, but this is not necessary; if you do so, it must be in the</span>
<span class="token comment" spellcheck="true"># range 1 to 255 inclusive and must be unique among all IDs specified</span>
<span class="token comment" spellcheck="true"># for cluster nodes.</span></code></pre>
  </div>
  <p>
   <b>
    Required my.cnf options for SQL nodes.
   </b>
   MySQL servers acting as NDB Cluster SQL nodes must always be
          started with the
   <a class="link" href="mysql-cluster-options-variables.html#option_mysqld_ndbcluster">
    <code class="option">
     --ndbcluster
    </code>
   </a>
   and
   <a class="link" href="mysql-cluster-options-variables.html#option_mysqld_ndb-connectstring">
    <code class="option">
     --ndb-connectstring
    </code>
   </a>
   options, either on the command line or in
   <code class="filename">
    my.cnf
   </code>
   .
  </p>
 </div>
 <br/>
</div>
