Cluster Disk Data is a new feature of MySQL? 5.1. Beginning with MySQL? 5.1.6, in fact, it is possible to store the non-indexed columns of NDBCLUSTER tables on disk, rather than in RAM this allowing MySQL? Cluster to scale upward with fewer RAM requirements than previously.
This is a short tutorial on the features implemented in HoneyMonitor for the use and administration of Cluster Disk Data Objects . It could be useful for Users who are new to the product and want to get start with it or to whom want to learn the basis of Cluster Disk Data in MySQL? 5.1.
For more information about Cluster Disk Data, please visit http://dev.mysql.com/doc/refman/5.1/en/mysql-cluster-disk-data.html, while, if you want to learn more on HoneyMonitor, please visit its Project Home Page at http://www.honeysoftware.com/honeymonitor.
For this tutorial we will suppose you have a MySQL? Cluster up and running and we will connect to the Linux machine, from HoneyMonitor, through a SSH Tunneling connection.
If you are new to MySQL? Cluster and want to set up a testbed (all nodes on localhost), you can use this very useful configuration tool (created by Johan Andersson) or, if you want to do a more complicated (but nice) exercise, you can set up the Cluster in 4 Solaris? Zones (a tutorial can be found here).
For our Tutorial, we will follow the following steps:
You can skip steps no. 2 and 4 as they are just to practise.
The LogFile Group Editor (Fig. 1) allows you create / edit / drop a LogFile Group.
Fig. 1: Creating a LogFile Group
It implements the following Data Definitions Statements:
1) [http://dev.mysql.com/doc/refman/5.1/en/create-logfile-group.html]
CREATE LOGFILE GROUP logfile_group
ADD UNDOFILE ‘undo_file’
[INITIAL_SIZE [=] initial_size]
[UNDO_BUFFER_SIZE [=] undo_buffer_size]
[REDO_BUFFER_SIZE [=] redo_buffer_size]
[NODEGROUP [=] nodegroup_id]
[WAIT]
[COMMENT [=] comment_text]
ENGINE [=] engine_name
2) [http://dev.mysql.com/doc/refman/5.1/en/alter-logfile-group.html]
ALTER LOGFILE GROUP logfile_group
ADD UNDOFILE ‘file_name’
[INITIAL_SIZE [=] size]
[WAIT]
ENGINE [=] engine_name
3) [http://dev.mysql.com/doc/refman/5.1/en/drop-logfile-group.html]
DROP LOGFILE GROUP logfile_group
ENGINE [=] engine_name
As you can see from Fig. 1, some options are disabled as they are parsed but not yet implemented by the MySQL? Server.
An UndoFile is required for the LogFile Group creation. In our example we will use an UndoFile named ‘undofile1′.
After the creation of the LogFile Group the Tabs ‘UndoFiles’ and SQL will be enabled (Fig. 2, 3, 4).
Fig. 2: LogFile Group Editor - Advanced Tab
Fig. 3: LogFile Group Editor - UndoFiles Tab
Fig. 4: LogFile Group Editor - SQL Tab
In the UndoFiles Tab you can see UndoFiles’ details or you can create one more UndoFile, using the Add UndoFile Dialog (Fig. 5).
Fig. 5: Add UndoFile Dialog
The SQL Tab contains the SQL statements to be executed for re-creating the LogFile Group (and all its UndoFiles!).
Note: you can’t delete UndoFiles.
Note 2: beginning with MySQL? 5.1.8, you can have only one LogFile Group per Cluster at any given time (see Bug#16386).
Let’s now create a TableSpace that uses the LogFile Group just created.
The TableSpace Editor (Fig. 6) allows you create / edit / drop TableSpaces.
Fig. 6: Creating a TableSpace
It implements the following Data Definitions Statements:
1) [http://dev.mysql.com/doc/refman/5.1/en/create-tablespace.html]
CREATE TABLESPACE tablespace_name
ADD DATAFILE ‘file_name’
USE LOGFILE GROUP logfile_group
[EXTENT_SIZE [=] extent_size]
[INITIAL_SIZE [=] initial_size]
[AUTOEXTEND_SIZE [=] autoextend_size]
[MAX_SIZE [=] max_size]
[NODEGROUP [=] nodegroup_id]
[WAIT]
[COMMENT [=] comment_text]
ENGINE [=] engine_name
2) [http://dev.mysql.com/doc/refman/5.1/en/alter-tablespace.html]
ALTER TABLESPACE tablespace_name
{ADD|DROP} DATAFILE ‘file_name’
[INITIAL_SIZE [=] size]
[WAIT]
ENGINE [=] engine_name
3) [http://dev.mysql.com/doc/refman/5.1/en/drop-tablespace.html]
DROP TABLESPACE tablespace_name
ENGINE [=] engine_name
Note: The Editor can be used to create both NDBCLUSTER and FALCON TableSpaces. When creating FALCON TableSpaces, the ‘LogFile Group’ option isn’t visible.
As you can see from Fig. 6, some options are disabled as they are parsed but not yet implemented by the MySQL? Server.
A DataFile is required for the TableSpace creation. In our example we will use a DataFile named ‘datafile-11′.
After the creation of the TableSpace the Tabs ‘DataFiles’ and SQL will be enabled (Fig. 7, 8, 9).
Fig. 7: TableSpace Editor - Advanced Tab
Fig. 8: TableSpace Editor - DataFiles Tab
Fig. 9: TableSpace Editor - SQL Tab
In the DataFiles Tab you can see DataFiles’ details or you can create one more DataFile, using the Add DataFile Dialog (Fig. 10). You can also drop a DataFile.
Fig. 10: Add DataFile Dialog
The SQL Tab contains the SQL statements to be executed for re-creating the TableSpace (and all its DataFiles!).
The source for Cluster Disk Object Metadata in MySQL? 5.1 is the information_schema.files table. I’ll try to post a more detailed article on Disk Object Metadata later on.
In the HoneyMonitor’s Metadata Catalog there is a visualization dedicated to Cluster Disk Objects (Fig. 11).
Fig. 11: Metadata Catalog - Cluster Disk Objects
That visualization is very useful to know, with just a look, the Cluster Disk Objects’ hierarchy. You can use popup menus to create / edit / drop the objects.
Now that our TableSpace has been created, we can create a Cluster Disk Table. We can use the command line client
CREATE TABLE my_disk_data_table (
….
)
TABLESPACE tablespace1 STORAGE DISK
ENGINE = NDBCLUSTER;
or the Create Table Wizard (Fig. 12).
Fig. 12: Creating a Cluster Disk Table
Please, note that there are particular rules for dropping Cluster Disk Data Objects. You have to follow a logical order. For more information, please refer to http://dev.mysql.com/doc/refman/5.1/en/mysql-cluster-disk-data-objects.html.
The Cluster Monitor (Fig. 13) allows you to monitor the status of your Cluster.
Fig. 13: The Cluster Monitor
At this stage of development it’s a simple (but useful) Window which shows information about the NDB Engine Status (at a glance or category by category) and the status, dynamic and system variables of the Server related to Cluster.
We plan to add new features for Cluster Management and Monitoring in HoneyMonitor, so stay tuned!
Disk Data Objects are subject to the following maximums:
For known limitations of MySQL Cluster, please refer to http://dev.mysql.com/doc/refman/5.1/en/mysql-cluster-limitations.html.
Create a LogFile Group, some TableSpaces and some Cluster Disk Tables. Then choose a TableSpace and write a query to find the list of the tables which are using that TableSpace.
It’s now time to close this article. If you want to learn more on HoneyMonitor please visit the Project Home Page, at http://www.honeysoftware.com/honeymonitor, or check out one of the following resources:
Enjoy your MySQL? Cluster!
On Windows® - but I guess it’s the same on another O.S. that does not support cluster - I noticed the following behavior when trying to execute a CREATE LOGFILE GROUP syntax like this:
CREATE
LOGFILE GROUP `test`
ADD UNDOFILE ‘test’
INITIAL_SIZE = 33M
UNDO_BUFFER_SIZE = 8M
ENGINE = NDBCLUSTER;
In v.5.1.25-rc, v.5.1.24-rc and v.5.1.23-rc, only SQL warnings are shown:
mysql> CREATE
-> LOGFILE GROUP `test`
-> ADD UNDOFILE ‘test’
-> INITIAL_SIZE = 33M
-> UNDO_BUFFER_SIZE = 8M
-> ENGINE = NDBCLUSTER;
Query OK, 0 rows affected, 2 warnings (0.01 sec)
mysql> SHOW WARNINGS;
+———+——+————————————————————————————————+
| Level | Code | Message
|
+———+——+————————————————————————————————+
| Warning | 1286 | Unknown table engine ‘NDBCLUSTER’
|
| Error | 1478 | Table storage engine ‘MyISAM’ does not support the create option ‘TABLESPACE or LOGFILE GROUP’ |
+———+——+————————————————————————————————+
2 rows in set (0.00 sec)
In v.6.0.5-alpha a SQL error occurs:
mysql> CREATE
-> LOGFILE GROUP `test`
-> ADD UNDOFILE ‘test’
-> INITIAL_SIZE = 33M
-> UNDO_BUFFER_SIZE = 8M
-> ENGINE = NDBCLUSTER;
ERROR 1478 (HY000): Table storage engine ‘MyISAM’ does not support the create option ‘TABLESPACE or LOGFILE GROUP’
This difference can generate a bug in your applications if you were using code like this:
IF mysql.error = 0 THEN
ok, post-creation operations
ELSE
error, do nothing
In fact, the code above is correct if used on v.6.0.5 but it is wrong if used on v.5.1.25 (the application executes the post-creation operations even if the logfile group hasn’t been created).
I don’t remember exactly which version, but an old 5.1.x version had the same behavior of v.6.0.5 - i.e. SQL error - and that was the reason why I coded in that way.
Well.. one more application-bug discovered while testing the version 6.0.5-alpha of the server.
This afternoon I changed the code in this way:
IF (mysql.error = 0 AND mysql.warnings=0) THEN
ok, post-creation operations
ELSE
error, do nothing
uhmm, I would like to read such changes (errors -> warnings) in the internal mailing list or in the release notes file of the server (indeed, I’m not sure if it’s included in the chapter “Changes in release 5.1.x”).
Moral:
opensource: del.icio.us tag/opensource
Data
visualization
analysis
logfile
website
opensource
datamining