<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="mysql-cluster-install-configuration">
      </a>
      25.3.3 Initial Configuration of NDB Cluster
     </h3>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045122266784">
  </a>
  <a class="indexterm" name="idm46045122265296">
  </a>
  <a class="indexterm" name="idm46045122263808">
  </a>
  <p>
   In this section, we discuss manual configuration of an installed
      NDB Cluster by creating and editing configuration files.
  </p>
  <p>
   For our four-node, four-host NDB Cluster (see
   <a class="xref" href="mysql-cluster-installation.html#mysql-cluster-install-nodes-hosts" title="Cluster nodes and host computers">
    Cluster nodes and host computers
   </a>
   ), it is
      necessary to write four configuration files, one per node host.
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Each data node or SQL node requires a
      <code class="filename">
       my.cnf
      </code>
      file that provides two pieces of
          information: a
      <span class="firstterm">
       connection
          string
      </span>
      that tells the node where to find the
          management node, and a line telling the MySQL server on this
          host (the machine hosting the data node) to enable the
      <a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
       <code class="literal">
        NDBCLUSTER
       </code>
      </a>
      storage engine.
     </p>
     <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>
    </li>
    <li class="listitem">
     <p>
      The management node needs a
      <code class="filename">
       config.ini
      </code>
      file telling it how many fragment replicas to maintain, how
          much memory to allocate for data and indexes on each data
          node, where to find the data nodes, where to save data to disk
          on each data node, and where to find any SQL nodes.
     </p>
    </li>
   </ul>
  </div>
  <p>
   <b>
    Configuring the data nodes and SQL nodes.
   </b>
   The
   <code class="filename">
    my.cnf
   </code>
   file needed for the data nodes
        is fairly simple. The configuration file should be located in
        the
   <code class="filename">
    /etc
   </code>
   directory and can be edited using
        any text editor. (Create the file if it does not exist.) For
        example:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa70025660"><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-terminal"><span class="token prompt">$&gt; </span><span class="token command">vi</span> /etc/my<span class="token punctuation">.</span>cnf</code></pre>
  </div>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    We show
    <span class="command">
     <strong>
      vi
     </strong>
    </span>
    being used here to create the
        file, but any text editor should work just as well.
   </p>
  </div>
  <p>
   For each data node and SQL node in our example setup,
   <code class="filename">
    my.cnf
   </code>
   should look like this:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa20040471"><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 selector">[mysqld]</span>
<span class="token comment" spellcheck="true"># Options for mysqld process:</span>
ndbcluster                      <span class="token comment" spellcheck="true"># run NDB storage engine</span>

<span class="token selector">[mysql_cluster]</span>
<span class="token comment" spellcheck="true"># Options for NDB Cluster processes:</span>
<span class="token constant">ndb-connectstring</span><span class="token attr-value"><span class="token punctuation">=</span>198.51.100.10  </span><span class="token comment" spellcheck="true"># location of management server</span></code></pre>
  </div>
  <p>
   After entering the preceding information, save this file and exit
      the text editor. Do this for the machines hosting data node
   <span class="quote">
    “
    <span class="quote">
     A
    </span>
    ”
   </span>
   , data node
   <span class="quote">
    “
    <span class="quote">
     B
    </span>
    ”
   </span>
   , and the SQL node.
  </p>
  <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
    <code class="literal">
     ndbcluster
    </code>
    and
    <code class="literal">
     ndb-connectstring
    </code>
    parameters in the
    <code class="literal">
     [mysqld]
    </code>
    and
    <code class="literal">
     [mysql_cluster]
    </code>
    sections of 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. This is by design.
   </p>
  </div>
  <p>
   <b>
    Configuring the management node.
   </b>
   The first step in configuring the management node is to create
        the directory in which the configuration file can be found and
        then to create the file itself. For example (running as
   <code class="literal">
    root
   </code>
   ):
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa82663910"><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-terminal"><span class="token prompt">$&gt; </span><span class="token command">mkdir</span> /var/lib/mysql-cluster
<span class="token prompt">$&gt; </span><span class="token command">cd</span> /var/lib/mysql-cluster
<span class="token prompt">$&gt; </span><span class="token command">vi</span> config<span class="token punctuation">.</span>ini</code></pre>
  </div>
  <p>
   For our representative setup, the
   <code class="filename">
    config.ini
   </code>
   file should read as follows:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa9860218"><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 selector">[ndbd default]</span>
<span class="token comment" spellcheck="true"># Options affecting ndbd processes on all data nodes:</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"># Number of fragment replicas</span>
<span class="token constant">DataMemory</span><span class="token attr-value"><span class="token punctuation">=</span>98M    </span><span class="token comment" spellcheck="true"># How much memory to allocate for data storage</span>

<span class="token selector">[ndb_mgmd]</span>
<span class="token comment" spellcheck="true"># Management process options:</span>
<span class="token constant">HostName</span><span class="token attr-value"><span class="token punctuation">=</span>198.51.100.10          </span><span class="token comment" spellcheck="true"># Hostname or IP address of management node</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 comment" spellcheck="true"># Directory for management node log files</span>

<span class="token selector">[ndbd]</span>
<span class="token comment" spellcheck="true"># Options for data node "A":</span>
<span class="token comment" spellcheck="true">                                # (one [ndbd] section per data node)</span>
<span class="token constant">HostName</span><span class="token attr-value"><span class="token punctuation">=</span>198.51.100.30          </span><span class="token comment" spellcheck="true"># Hostname or IP address</span>
<span class="token constant">NodeId</span><span class="token attr-value"><span class="token punctuation">=</span>2                        </span><span class="token comment" spellcheck="true"># Node ID for this data node</span>
<span class="token constant">DataDir</span><span class="token attr-value"><span class="token punctuation">=</span>/usr/local/mysql/data   </span><span class="token comment" spellcheck="true"># Directory for this data node's data files</span>

<span class="token selector">[ndbd]</span>
<span class="token comment" spellcheck="true"># Options for data node "B":</span>
<span class="token constant">HostName</span><span class="token attr-value"><span class="token punctuation">=</span>198.51.100.40          </span><span class="token comment" spellcheck="true"># Hostname or IP address</span>
<span class="token constant">NodeId</span><span class="token attr-value"><span class="token punctuation">=</span>3                        </span><span class="token comment" spellcheck="true"># Node ID for this data node</span>
<span class="token constant">DataDir</span><span class="token attr-value"><span class="token punctuation">=</span>/usr/local/mysql/data   </span><span class="token comment" spellcheck="true"># Directory for this data node's data files</span>

<span class="token selector">[mysqld]</span>
<span class="token comment" spellcheck="true"># SQL node options:</span>
<span class="token constant">HostName</span><span class="token attr-value"><span class="token punctuation">=</span>198.51.100.20          </span><span class="token comment" spellcheck="true"># Hostname or IP address</span>
<span class="token comment" spellcheck="true">                                # (additional mysqld connections can be</span>
<span class="token comment" spellcheck="true">                                # specified for this node for various</span>
<span class="token comment" spellcheck="true">                                # purposes such as running ndb_restore)</span></code></pre>
  </div>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    The
    <code class="literal">
     world
    </code>
    database can be downloaded from
    <a class="ulink" href="/doc/index-other.html" target="_top">
     https://dev.mysql.com/doc/index-other.html
    </a>
    .
   </p>
  </div>
  <p>
   After all the configuration files have been created and these
      minimal options have been specified, you are ready to proceed with
      starting the cluster and verifying that all processes are running.
      We discuss how this is done in
   <a class="xref" href="mysql-cluster-install-first-start.html" title="25.3.4 Initial Startup of NDB Cluster">
    Section 25.3.4, “Initial Startup of NDB Cluster”
   </a>
   .
  </p>
  <p>
   For more detailed information about the available NDB Cluster
      configuration parameters and their uses, see
   <a class="xref" href="mysql-cluster-config-file.html" title="25.4.3 NDB Cluster Configuration Files">
    Section 25.4.3, “NDB Cluster Configuration Files”
   </a>
   , and
   <a class="xref" href="mysql-cluster-configuration.html" title="25.4 Configuration of NDB Cluster">
    Section 25.4, “Configuration of NDB Cluster”
   </a>
   . For configuration
      of NDB Cluster as relates to making backups, see
   <a class="xref" href="mysql-cluster-backup-configuration.html" title="25.6.8.3 Configuration for NDB Cluster Backups">
    Section 25.6.8.3, “Configuration for NDB Cluster Backups”
   </a>
   .
  </p>
  <p>
   The default port for Cluster management nodes is 1186. For data
      nodes, the cluster can automatically allocate ports from those
      that are already free.
  </p>
 </div>
 <br/>
</div>
