<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="mysql-cluster-config-example">
      </a>
      25.4.3.1 NDB Cluster Configuration: Basic Example
     </h4>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045120743520">
  </a>
  <a class="indexterm" name="idm46045120742032">
  </a>
  <a class="indexterm" name="idm46045120740544">
  </a>
  <p>
   To support NDB Cluster, you should update
   <code class="filename">
    my.cnf
   </code>
   as shown in the following example.
        You may also specify these parameters on the command line when
        invoking the executables.
  </p>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    The options shown here should not be confused with those that
          are used in
    <code class="filename">
     config.ini
    </code>
    global
          configuration files. Global configuration options are
          discussed later in this section.
   </p>
  </div>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa47666699"><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"># my.cnf</span>
<span class="token comment" spellcheck="true"># example additions to my.cnf for NDB Cluster</span>
<span class="token comment" spellcheck="true"># (valid in MySQL 8.4)</span>

<span class="token comment" spellcheck="true"># enable ndbcluster storage engine, and provide connection string for</span>
<span class="token comment" spellcheck="true"># management server host (default port is 1186)</span>
<span class="token selector">[mysqld]</span>
<span class="token constant">ndbcluster</span>
<span class="token constant">ndb-connectstring</span><span class="token attr-value"><span class="token punctuation">=</span>ndb_mgmd.mysql.com</span>


<span class="token comment" spellcheck="true"># provide connection string for management server host (default port: 1186)</span>
<span class="token selector">[ndbd]</span>
<span class="token constant">connect-string</span><span class="token attr-value"><span class="token punctuation">=</span>ndb_mgmd.mysql.com</span>

<span class="token comment" spellcheck="true"># provide connection string for management server host (default port: 1186)</span>
<span class="token selector">[ndb_mgm]</span>
<span class="token constant">connect-string</span><span class="token attr-value"><span class="token punctuation">=</span>ndb_mgmd.mysql.com</span>

<span class="token comment" spellcheck="true"># provide location of cluster configuration file</span>
<span class="token comment" spellcheck="true"># IMPORTANT: When starting the management server with this option in the</span>
<span class="token comment" spellcheck="true"># configuration file, the use of --initial or --reload on the command line when</span>
<span class="token comment" spellcheck="true"># invoking ndb_mgmd is also required.</span>
<span class="token selector">[ndb_mgmd]</span>
<span class="token constant">config-file</span><span class="token attr-value"><span class="token punctuation">=</span>/etc/config.ini</span></code></pre>
  </div>
  <p>
   (For more information on connection strings, see
   <a class="xref" href="mysql-cluster-connection-strings.html" title="25.4.3.3 NDB Cluster Connection Strings">
    Section 25.4.3.3, “NDB Cluster Connection Strings”
   </a>
   .)
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa368294"><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"># my.cnf</span>
<span class="token comment" spellcheck="true"># example additions to my.cnf for NDB Cluster</span>
<span class="token comment" spellcheck="true"># (works on all versions)</span>

<span class="token comment" spellcheck="true"># enable ndbcluster storage engine, and provide connection string for management</span>
<span class="token comment" spellcheck="true"># server host to the default port 1186</span>
<span class="token selector">[mysqld]</span>
<span class="token constant">ndbcluster</span>
<span class="token constant">ndb-connectstring</span><span class="token attr-value"><span class="token punctuation">=</span>ndb_mgmd.mysql.com:1186</span></code></pre>
  </div>
  <div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Important
   </div>
   <p>
    Once you have started a
    <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
     <span class="command">
      <strong>
       mysqld
      </strong>
     </span>
    </a>
    process with
          the
    <a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
     <code class="literal">
      NDBCLUSTER
     </code>
    </a>
    and
    <code class="literal">
     ndb-connectstring
    </code>
    parameters in the
    <code class="literal">
     [mysqld]
    </code>
    in the
    <code class="filename">
     my.cnf
    </code>
    file as shown previously, you cannot execute any
    <a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
     <code class="literal">
      CREATE TABLE
     </code>
    </a>
    or
    <a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
     <code class="literal">
      ALTER TABLE
     </code>
    </a>
    statements without
          having actually started the cluster. Otherwise, these
          statements fail with an error.
    <span class="emphasis">
     <em>
      This is by
          design
     </em>
    </span>
    .
   </p>
  </div>
  <p>
   You may also use a separate
   <code class="literal">
    [mysql_cluster]
   </code>
   section in the cluster
   <code class="filename">
    my.cnf
   </code>
   file for
        settings to be read and used by all executables:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa47590244"><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"># cluster-specific settings</span>
<span class="token selector">[mysql_cluster]</span>
<span class="token constant">ndb-connectstring</span><span class="token attr-value"><span class="token punctuation">=</span>ndb_mgmd.mysql.com:1186</span></code></pre>
  </div>
  <p>
   For additional
   <a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
    <code class="literal">
     NDB
    </code>
   </a>
   variables that
        can be set in the
   <code class="filename">
    my.cnf
   </code>
   file, see
   <a class="xref" href="mysql-cluster-options-variables.html#mysql-cluster-system-variables" title="25.4.3.9.2 NDB Cluster System Variables">
    Section 25.4.3.9.2, “NDB Cluster System Variables”
   </a>
   .
  </p>
  <p>
   The NDB Cluster global configuration file is by convention named
   <code class="filename">
    config.ini
   </code>
   (but this is not required). If
        needed, it is read by
   <a class="link" href="mysql-cluster-programs-ndb-mgmd.html" title="25.5.4 ndb_mgmd — The NDB Cluster Management Server Daemon">
    <span class="command">
     <strong>
      ndb_mgmd
     </strong>
    </span>
   </a>
   at startup and
        can be placed in any location that can be read by it. The
        location and name of the configuration are specified using
   <a class="link" href="mysql-cluster-programs-ndb-mgmd.html#option_ndb_mgmd_config-file">
    <code class="option">
     --config-file=
     <em class="replaceable">
      <code>
       path_name
      </code>
     </em>
    </code>
   </a>
   with
   <a class="link" href="mysql-cluster-programs-ndb-mgmd.html" title="25.5.4 ndb_mgmd — The NDB Cluster Management Server Daemon">
    <span class="command">
     <strong>
      ndb_mgmd
     </strong>
    </span>
   </a>
   on the command line. This
        option has no default value, and is ignored if
   <a class="link" href="mysql-cluster-programs-ndb-mgmd.html" title="25.5.4 ndb_mgmd — The NDB Cluster Management Server Daemon">
    <span class="command">
     <strong>
      ndb_mgmd
     </strong>
    </span>
   </a>
   uses the configuration cache.
  </p>
  <p>
   The global configuration file for NDB Cluster uses INI format,
        which consists of sections preceded by section headings
        (surrounded by square brackets), followed by the appropriate
        parameter names and values. One deviation from the standard INI
        format is that the parameter name and value can be separated by
        a colon (
   <code class="literal">
    :
   </code>
   ) as well as the equal sign
        (
   <code class="literal">
    =
   </code>
   ); however, the equal sign is preferred.
        Another deviation is that sections are not uniquely identified
        by section name. Instead, unique sections (such as two different
        nodes of the same type) are identified by a unique ID specified
        as a parameter within the section.
  </p>
  <p>
   Default values are defined for most parameters, and can also be
        specified in
   <code class="filename">
    config.ini
   </code>
   . To create a
        default value section, simply add the word
   <code class="literal">
    default
   </code>
   to the section name. For example, an
   <code class="literal">
    [ndbd]
   </code>
   section contains parameters that apply
        to a particular data node, whereas an
   <code class="literal">
    [ndbd
        default]
   </code>
   section contains parameters that apply to all
        data nodes. Suppose that all data nodes should use the same data
        memory size. To configure them all, create an
   <code class="literal">
    [ndbd
        default]
   </code>
   section that contains a
   <a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-datamemory">
    <code class="literal">
     DataMemory
    </code>
   </a>
   line to
        specify the data memory size.
  </p>
  <p>
   If used, the
   <code class="literal">
    [ndbd default]
   </code>
   section must
        precede any
   <code class="literal">
    [ndbd]
   </code>
   sections in the
        configuration file. This is also true for
   <code class="literal">
    default
   </code>
   sections of any other type.
  </p>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    In some older releases of NDB Cluster, there was no default
          value for
    <a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-noofreplicas">
     <code class="literal">
      NoOfReplicas
     </code>
    </a>
    , which
          always had to be specified explicitly in the
    <code class="literal">
     [ndbd
          default]
    </code>
    section. Although this parameter now has a
          default value of 2, which is the recommended setting in most
          common usage scenarios, it is still recommended practice to
          set this parameter explicitly.
   </p>
  </div>
  <p>
   The global configuration file must define the computers and
        nodes involved in the cluster and on which computers these nodes
        are located. An example of a simple configuration file for a
        cluster consisting of one management server, two data nodes and
        two MySQL servers is shown here:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa76558969"><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"># file "config.ini" - 2 data nodes and 2 SQL nodes</span>
<span class="token comment" spellcheck="true"># This file is placed in the startup directory of ndb_mgmd (the</span>
<span class="token comment" spellcheck="true"># management server)</span>
<span class="token comment" spellcheck="true"># The first MySQL Server can be started from any host. The second</span>
<span class="token comment" spellcheck="true"># can be started only on the host mysqld_5.mysql.com</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 constant">DataDir</span><span class="token attr-value"><span class="token punctuation">=</span> /var/lib/mysql-cluster</span>

<span class="token selector">[ndb_mgmd]</span>
<span class="token constant">Hostname</span><span class="token attr-value"><span class="token punctuation">=</span> ndb_mgmd.mysql.com</span>
<span class="token constant">DataDir</span><span class="token attr-value"><span class="token punctuation">=</span> /var/lib/mysql-cluster</span>

<span class="token selector">[ndbd]</span>
<span class="token constant">HostName</span><span class="token attr-value"><span class="token punctuation">=</span> ndbd_2.mysql.com</span>

<span class="token selector">[ndbd]</span>
<span class="token constant">HostName</span><span class="token attr-value"><span class="token punctuation">=</span> ndbd_3.mysql.com</span>

<span class="token selector">[mysqld]</span>
<span class="token selector">[mysqld]</span>
<span class="token constant">HostName</span><span class="token attr-value"><span class="token punctuation">=</span> mysqld_5.mysql.com</span></code></pre>
  </div>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    The preceding example is intended as a minimal starting
          configuration for purposes of familiarization with NDB Cluster
          , and is almost certain not to be sufficient for production
          settings. See
    <a class="xref" href="mysql-cluster-config-starting.html" title="25.4.3.2 Recommended Starting Configuration for NDB Cluster">
     Section 25.4.3.2, “Recommended Starting Configuration for NDB Cluster”
    </a>
    ,
          which provides a more complete example starting configuration.
   </p>
  </div>
  <p>
   Each node has its own section in the
   <code class="filename">
    config.ini
   </code>
   file. For example, this cluster
        has two data nodes, so the preceding configuration file contains
        two
   <code class="literal">
    [ndbd]
   </code>
   sections defining these nodes.
  </p>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    Do not place comments on the same line as a section heading in
          the
    <code class="filename">
     config.ini
    </code>
    file; this causes the
          management server not to start because it cannot parse the
          configuration file in such cases.
   </p>
  </div>
  <h5>
   <a name="mysql-cluster-config-ini-sections">
   </a>
   Sections of the config.ini File
  </h5>
  <p>
   There are six different sections that you can use in the
   <code class="filename">
    config.ini
   </code>
   configuration file, as described
        in the following list:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <code class="literal">
       [computer]
      </code>
      : Defines cluster hosts. This
            is not required to configure a viable NDB Cluster, but be
            may used as a convenience when setting up a large cluster.
            See
      <a class="xref" href="mysql-cluster-computer-definition.html" title="25.4.3.4 Defining Computers in an NDB Cluster">
       Section 25.4.3.4, “Defining Computers in an NDB Cluster”
      </a>
      , for
            more information.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       [ndbd]
      </code>
      : Defines a cluster data node
            (
      <a class="link" href="mysql-cluster-programs-ndbd.html" title="25.5.1 ndbd — The NDB Cluster Data Node Daemon">
       <span class="command">
        <strong>
         ndbd
        </strong>
       </span>
      </a>
      process). See
      <a class="xref" href="mysql-cluster-ndbd-definition.html" title="25.4.3.6 Defining NDB Cluster Data Nodes">
       Section 25.4.3.6, “Defining NDB Cluster Data Nodes”
      </a>
      , for
            details.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       [mysqld]
      </code>
      : Defines the cluster's MySQL
            server nodes (also called SQL or API nodes). For a
            discussion of SQL node configuration, see
      <a class="xref" href="mysql-cluster-api-definition.html" title="25.4.3.7 Defining SQL and Other API Nodes in an NDB Cluster">
       Section 25.4.3.7, “Defining SQL and Other API Nodes in an NDB Cluster”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       [mgm]
      </code>
      or
      <code class="literal">
       [ndb_mgmd]
      </code>
      :
            Defines a cluster management server (MGM) node. For
            information concerning the configuration of management
            nodes, see
      <a class="xref" href="mysql-cluster-mgm-definition.html" title="25.4.3.5 Defining an NDB Cluster Management Server">
       Section 25.4.3.5, “Defining an NDB Cluster Management Server”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       [tcp]
      </code>
      : Defines a TCP/IP connection
            between cluster nodes, with TCP/IP being the default
            transport protocol. Normally,
      <code class="literal">
       [tcp]
      </code>
      or
      <code class="literal">
       [tcp default]
      </code>
      sections are not required
            to set up an NDB Cluster, as the cluster handles this
            automatically; however, it may be necessary in some
            situations to override the defaults provided by the cluster.
            See
      <a class="xref" href="mysql-cluster-tcp-definition.html" title="25.4.3.10 NDB Cluster TCP/IP Connections">
       Section 25.4.3.10, “NDB Cluster TCP/IP Connections”
      </a>
      , for
            information about available TCP/IP configuration parameters
            and how to use them. (You may also find
      <a class="xref" href="mysql-cluster-tcp-definition-direct.html" title="25.4.3.11 NDB Cluster TCP/IP Connections Using Direct Connections">
       Section 25.4.3.11, “NDB Cluster TCP/IP Connections Using Direct Connections”
      </a>
      to be
            of interest in some cases.)
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       [shm]
      </code>
      : Defines shared-memory connections
            between nodes. In MySQL 8.4, it is enabled by
            default, but should still be considered experimental. For a
            discussion of SHM interconnects, see
      <a class="xref" href="mysql-cluster-shm-definition.html" title="25.4.3.12 NDB Cluster Shared-Memory Connections">
       Section 25.4.3.12, “NDB Cluster Shared-Memory Connections”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       [sci]
      </code>
      : Defines Scalable Coherent
            Interface connections between cluster data nodes. Not
            supported in NDB 8.4.
     </p>
    </li>
   </ul>
  </div>
  <p>
   You can define
   <code class="literal">
    default
   </code>
   values for each
        section. If used, a
   <code class="literal">
    default
   </code>
   section should
        come before any other sections of that type. For example, an
   <code class="literal">
    [ndbd default]
   </code>
   section should appear in the
        configuration file before any
   <code class="literal">
    [ndbd]
   </code>
   sections.
  </p>
  <p>
   NDB Cluster parameter names are case-insensitive, unless
        specified in MySQL Server
   <code class="filename">
    my.cnf
   </code>
   or
   <code class="filename">
    my.ini
   </code>
   files.
  </p>
 </div>
 <br/>
</div>
