content_image/697634.jpg
Undo log files are used only by Disk Data tables, and are not needed or used by NDB  tables that are stored in memory only. 

NDB Cluster tablespaces and log file groups are not implemented as files. 

Although not all Disk Data objects are implemented as files, they all share the same namespace. This means that each Disk Data object  must be uniquely named (and not merely each Disk Data object of a given type). For example, you cannot have a tablespace and a log file group both named dd1 . 

Assuming that you have already set up an NDB Cluster with all nodes (including management and SQL nodes), the basic steps for creating an NDB Cluster table on disk are as follows: 

1. Create a log file group, and assign one or more undo log files to it (an undo log file is also sometimes referred to as an undofile ). 

2. Create a tablespace; assign the log file group, as well as one or more data files, to the tablespace. 

3. Create a Disk Data table that uses this tablespace for data storage. 

Each of these tasks can be accomplished using SQL statements in the mysql  client or other MySQL client application, as shown in the example that follows. 

1.  We create a log file group named lg_1  using CREATE LOGFILE GROUP . This log file group is to be made up of two undo log files, which we name undo_1.log  and undo_2.log , whose initial sizes are 16 MB and 12 MB, respectively. (The default initial size for an undo log file is 128 MB.) Optionally, you can also specify a size for the log file group’s undo buffer, or permit it to assume the default value of 8 MB. In this example, we set the UNDO buffer’s size at 2 MB. A log file group must be created with an undo log file; so we add undo_1.log  to lg_1  in this CREATE LOGFILE GROUP  statement: 

CREATE LOGFILE GROUP lg_1 ADD UNDOFILE ’undo_1.log’ INITIAL_SIZE 16M UNDO_BUFFER_SIZE 2M ENGINE NDBCLUSTER; 

To add undo_2.log  to the log file group, use the following ALTER LOGFILE GROUP  statement: 

ALTER LOGFILE GROUP lg_1 ADD UNDOFILE ’undo_2.log’ INITIAL_SIZE 12M ENGINE NDBCLUSTER; 

Some items of note: 

•The .log  file extension used here is not required. We employ it merely to make the log files easily recognizable. 

•Every CREATE LOGFILE GROUP  and ALTER LOGFILE GROUP  statement must include an ENGINE option. The only permitted values for this option are NDBCLUSTER  and NDB . 

<img src='content_image/697634.jpg'>

## Important 

There can exist at most one log file group in the same NDB Cluster at any given time. 

•When you add an undo log file to a log file group using ADD UNDOFILE ’ filename ’ , a file with the name filename  is created in the ndb_ node_id _fs  directory within the DataDir  of each data node in the cluster, where node_id  is the node ID of the data node. Each undo log file is of the size specified in the SQL statement. For example, if an NDB Cluster has 4 data nodes, then the ALTER 

