<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="mysql-cluster-quick">
      </a>
      25.4.1 Quick Test Setup of NDB Cluster
     </h3>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045122003648">
  </a>
  <a class="indexterm" name="idm46045122002192">
  </a>
  <a class="indexterm" name="idm46045122000704">
  </a>
  <p>
   To familiarize you with the basics, we describe the simplest
      possible configuration for a functional NDB Cluster. After this,
      you should be able to design your desired setup from the
      information provided in the other relevant sections of this
      chapter.
  </p>
  <p>
   First, you need to create a configuration directory such as
   <code class="filename">
    /var/lib/mysql-cluster
   </code>
   , by executing the
      following command as the system
   <code class="literal">
    root
   </code>
   user:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa96211790"><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</code></pre>
  </div>
  <p>
   In this directory, create a file named
   <code class="filename">
    config.ini
   </code>
   that contains the following
      information. Substitute appropriate values for
   <code class="literal">
    HostName
   </code>
   and
   <code class="literal">
    DataDir
   </code>
   as
      necessary for your system.
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa82302769"><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" - showing minimal setup consisting of 1 data node,</span>
<span class="token comment" spellcheck="true"># 1 management server, and 3 MySQL servers.</span>
<span class="token comment" spellcheck="true"># The empty default sections are not required, and are shown only for</span>
<span class="token comment" spellcheck="true"># the sake of completeness.</span>
<span class="token comment" spellcheck="true"># Data nodes must provide a hostname but MySQL Servers are not required</span>
<span class="token comment" spellcheck="true"># to do so.</span>
<span class="token comment" spellcheck="true"># If you do not know the hostname for your machine, use localhost.</span>
<span class="token comment" spellcheck="true"># The DataDir parameter also has a default value, but it is recommended to</span>
<span class="token comment" spellcheck="true"># set it explicitly.</span>
<span class="token comment" spellcheck="true"># [api] and [mgm] are aliases for [mysqld] and [ndb_mgmd], respectively.</span>

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

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

<span class="token selector">[ndb_mgmd]</span>
<span class="token constant">HostName</span><span class="token attr-value"><span class="token punctuation">=</span> myhost.example.com</span>

<span class="token selector">[ndbd]</span>
<span class="token constant">HostName</span><span class="token attr-value"><span class="token punctuation">=</span> myhost.example.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">[mysqld]</span>
<span class="token selector">[mysqld]</span>
<span class="token selector">[mysqld]</span></code></pre>
  </div>
  <p>
   You can now start the
   <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>
   management
      server. By default, it attempts to read the
   <code class="filename">
    config.ini
   </code>
   file in its current working
      directory, so change location into the directory where the file is
      located and then invoke
   <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>
   :
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa70209928"><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">cd</span> /var/lib/mysql-cluster
<span class="token prompt">$&gt; </span><span class="token command">ndb_mgmd</span></code></pre>
  </div>
  <p>
   Then start a single data node by running
   <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>
   :
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa39743877"><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">ndbd</span></code></pre>
  </div>
  <p>
   By default,
   <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>
   looks for the management
      server at
   <code class="literal">
    localhost
   </code>
   on port 1186.
  </p>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    If you have installed MySQL from a binary tarball, you must to
        specify the path of the
    <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>
    and
    <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>
    servers explicitly. (Normally, these can
        be found in
    <code class="filename">
     /usr/local/mysql/bin
    </code>
    .)
   </p>
  </div>
  <p>
   Finally, change location to the MySQL data directory (usually
   <code class="filename">
    /var/lib/mysql
   </code>
   or
   <code class="filename">
    /usr/local/mysql/data
   </code>
   ), and make sure that
      the
   <code class="filename">
    my.cnf
   </code>
   file contains the option necessary
      to enable the NDB storage engine:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa43644783"><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 constant">ndbcluster</span></code></pre>
  </div>
  <p>
   You can now start the MySQL server as usual:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa11789097"><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">mysqld_safe</span> <span class="token constant">--user</span><span class="token attr-value"><span class="token punctuation">=</span>mysql</span> &amp;</code></pre>
  </div>
  <p>
   Wait a moment to make sure the MySQL server is running properly.
      If you see the notice
   <code class="literal">
    mysql ended
   </code>
   , check the
      server's
   <code class="filename">
    .err
   </code>
   file to find out what went
      wrong.
  </p>
  <p>
   If all has gone well so far, you now can start using the cluster.
      Connect to the server and verify that the
   <a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
    <code class="literal">
     NDBCLUSTER
    </code>
   </a>
   storage engine is enabled:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa36151102"><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-sql">$<span class="token operator">&gt;</span> mysql
Welcome <span class="token keyword">to</span> the MySQL monitor<span class="token punctuation">.</span>  Commands <span class="token keyword">end</span> <span class="token keyword">with</span> <span class="token punctuation">;</span> <span class="token operator">or</span> \g<span class="token punctuation">.</span>
Your MySQL <span class="token keyword">connection</span> id <span class="token operator">is</span> <span class="token number">1</span> <span class="token keyword">to</span> <span class="token keyword">server</span> version: <span class="token number">8.4</span><span class="token punctuation">.</span><span class="token number">3</span>

<span class="token keyword">Type</span> <span class="token string">'help;'</span> <span class="token operator">or</span> <span class="token string">'\h'</span> <span class="token keyword">for</span> <span class="token keyword">help</span><span class="token punctuation">.</span> <span class="token keyword">Type</span> <span class="token string">'\c'</span> <span class="token keyword">to</span> clear the buffer<span class="token punctuation">.</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SHOW</span> <span class="token keyword">ENGINES</span>\G
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 12. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
Engine<span class="token punctuation">:</span> NDBCLUSTER
Support<span class="token punctuation">:</span> YES
Comment<span class="token punctuation">:</span> Clustered, fault-tolerant, memory-based tables
<span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 13. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
Engine<span class="token punctuation">:</span> NDB
Support<span class="token punctuation">:</span> YES
Comment<span class="token punctuation">:</span> Alias for NDBCLUSTER
...</span></code></pre>
  </div>
  <p>
   The row numbers shown in the preceding example output may be
      different from those shown on your system, depending upon how your
      server is configured.
  </p>
  <p>
   Try to create an
   <a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
    <code class="literal">
     NDBCLUSTER
    </code>
   </a>
   table:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa16444736"><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-sql">$<span class="token operator">&gt;</span> mysql
<span class="token prompt">mysql&gt;</span> <span class="token keyword">USE</span> test<span class="token punctuation">;</span>
<span class="token keyword">Database</span> <span class="token keyword">changed</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> ctest <span class="token punctuation">(</span>i <span class="token datatype">INT</span><span class="token punctuation">)</span> <span class="token keyword">ENGINE</span><span class="token operator">=</span><span class="token keyword">NDBCLUSTER</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.09 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SHOW</span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> ctest \G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
       Table<span class="token punctuation">:</span> ctest
Create Table<span class="token punctuation">:</span> CREATE TABLE `ctest` (
  `i` int(11) default NULL
) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
</span><span class="token output">1 row in set (0.00 sec)</span></code></pre>
  </div>
  <p>
   To check that your nodes were set up properly, start the
      management client:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa11350256"><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">ndb_mgm</span></code></pre>
  </div>
  <a class="indexterm" name="idm46045121953184">
  </a>
  <p>
   Use the
   <span class="command">
    <strong>
     SHOW
    </strong>
   </span>
   command from within the management
      client to obtain a report on the cluster's status:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-ndbmgm"><div class="docs-select-all right" id="sa85074722"><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-ndbmgm"><span class="token prompt">ndb_mgm&gt;</span> <span class="token keyword">SHOW</span>
Cluster Configuration
<span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">-</span>
<span class="token selector">[ndbd(NDB)]</span>     1 node<span class="token punctuation">(</span>s<span class="token punctuation">)</span>
id<span class="token operator">=</span>2    @127<span class="token punctuation">.</span>0<span class="token punctuation">.</span>0<span class="token punctuation">.</span>1  <span class="token punctuation">(</span>Version<span class="token operator">:</span> 8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token operator">-</span>ndb<span class="token operator">-</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token punctuation">,</span> Nodegroup<span class="token operator">:</span> 0<span class="token punctuation">,</span> <span class="token operator">*</span><span class="token punctuation">)</span>

<span class="token selector">[ndb_mgmd(MGM)]</span> 1 node<span class="token punctuation">(</span>s<span class="token punctuation">)</span>
id<span class="token operator">=</span>1    @127<span class="token punctuation">.</span>0<span class="token punctuation">.</span>0<span class="token punctuation">.</span>1  <span class="token punctuation">(</span>Version<span class="token operator">:</span> 8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token operator">-</span>ndb<span class="token operator">-</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token punctuation">)</span>

<span class="token selector">[mysqld(API)]</span>   3 node<span class="token punctuation">(</span>s<span class="token punctuation">)</span>
id<span class="token operator">=</span>3    @127<span class="token punctuation">.</span>0<span class="token punctuation">.</span>0<span class="token punctuation">.</span>1  <span class="token punctuation">(</span>Version<span class="token operator">:</span> 8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token operator">-</span>ndb<span class="token operator">-</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token punctuation">)</span>
id<span class="token operator">=</span>4 <span class="token punctuation">(</span>not connected<span class="token punctuation">,</span> accepting connect from any host<span class="token punctuation">)</span>
id<span class="token operator">=</span>5 <span class="token punctuation">(</span>not connected<span class="token punctuation">,</span> accepting connect from any host<span class="token punctuation">)</span></code></pre>
  </div>
  <p>
   At this point, you have successfully set up a working NDB Cluster.
      You can now store data in the cluster by using any table created
      with
   <code class="literal">
    ENGINE=NDBCLUSTER
   </code>
   or its alias
   <code class="literal">
    ENGINE=NDB
   </code>
   .
  </p>
 </div>
 <br/>
</div>
