{"id":219,"date":"2007-09-19T04:42:34","date_gmt":"2007-09-19T03:42:34","guid":{"rendered":"http:\/\/www.nivas.hr\/blog\/2007\/09\/19\/fun-with-ndbcluster\/"},"modified":"2007-09-19T04:42:34","modified_gmt":"2007-09-19T03:42:34","slug":"fun-with-ndbcluster","status":"publish","type":"post","link":"https:\/\/www.nivas.hr\/blog\/2007\/09\/19\/fun-with-ndbcluster\/","title":{"rendered":"Fun with NDBCLUSTER"},"content":{"rendered":"<p>MySQL 5.0 introduced NDB Cluster, a storage engine which enables running several MySQL servers in a cluster. It uses high-availability, high-redundancy version of MySQL adapted for the distributed computing environment. This all sounds really nice, and in theory, depending on your application and scalability planning, it could spare you MANY hours of developing (squeezing) database logic inside your application logic which then gets highly dependable on master\/slave (active-pasive) configuration. And of course best reason of them all &#8211; instant failover.  So I decided to give it a try. I used MySQL 5.0.45-0, because 5.1 sounded too much bleeding edge.<\/p>\n<p>MySQL Cluster is currently not supported on Microsoft Windows, you&#8217;ll have to install it somewhere else. Once you have it running, it&#8217;s time to import some data. Database schema of a my test dump mostly used MyIsam storage engine and few InnoDB tables. Before the import, change Engine=NDB in the dump and be aware, import takes ages even on a really fast servers (200 kb dump = cca 1 min ??). <\/p>\n<p>My best guess is, you will see a lot of HY00 errors when you start your import. Be patient, check one by one. Most of them are caused by non supported features of NDB but can be avoided. <\/p>\n<p>Here is a brief coverage of reasons for the problems which I encountered:<\/p>\n<ul>\n<li>NDB does not support foreign keys or FULLTEXT indexes or indexes on text columns (indexes on char\/varchar are ok). <\/li>\n<li>Attribute names are automatically truncated to 31 characters. Database names and table names can total a maximum of 122 characters &#8211; the maximum length for an NDB table name is 122 characters, less the number of characters in the name of the database of which that table is a part.<\/li>\n<li>The maximum number columns and indexes per table is limited to 128.<\/li>\n<li>Temporary tables are not supported.<\/li>\n<li>Every table using the NDBCluster storage engine requires a primary key; if no primary key is defined by the user, then a \u201chidden\u201d primary key will be created by NDB. This hidden primary key consumes 31-35 bytes per table record.<\/li>\n<li>The maximum permitted size of any one row is 8KB. Note that each BLOB or TEXT column adds 256 + 8 = 264 bytes towards this total.<\/li>\n<\/ul>\n<p>The last error is really nasty one and will cause you to rethink your database schema and make a lot of changes to your application):<br \/>\n<code><br \/>\nERROR 1118 (42000) at line 794: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8052. You have to change some columns to TEXT or BLOBs<br \/>\n<\/code><\/p>\n<p>Some help:<\/p>\n<ul>\n<li>The lack of foreign keys, can be resolved by using triggers (<a href=\"http:\/\/dev.mysql.com\/tech-resources\/articles\/mysql-enforcing-foreign-keys.html\">Enforcing Foreign Keys Programmatically in MySQL<\/a>).<\/li>\n<li>You need a lot of RAM in your severs because all data is in the RAM, unless you are using the &#8216;DATA ON DISK&#8217; feature of MySQL 5.1.x. In that case you can have the non-indexed data on disk.<\/li>\n<li>When calculating Cluster memory requirements, very useful is <a href=\"http:\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/mysql-cluster-utilities-ndb-size.html\">ndb_size.pl<\/a> utility. This Perl script connects to a current MySQL (non-Cluster) database and creates a report on how much space that database would require if it used the NDBCluster storage engine. When you run the script, compare the suggested parameter values reported for your database to the default values for each shown <a href=\"http:\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/mysql-cluster-config-params-ndbd.html\">here<\/a>. If the default is higher than the recommended value from ndb_size.pl do not adjust the value. If the recommended vales are lower than the defaults use slightly larger numbers.<\/li>\n<\/ul>\n<p>NDBCluster is something I&#8217;ll definitively have my four eyes on and watch it grow. Bugtracker on mysql is crawling with bugs, but this is something to be expected. I&#8217;ve tested 5.0, and there is a lot of stuff allready fixed in 5.1. My biggest disappointment was the fact that new nodes can&#8217;t be added to the cluster without shutting it down first. My conclusion is, that It is not yet ready for prime time. When it will be? when 5.1 is released into production I guess. Until then&#8230; We are on our own. :)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MySQL 5.0 introduced NDB Cluster, a storage engine which enables running several MySQL servers in a cluster. It uses high-availability, high-redundancy version of MySQL adapted for the distributed computing environment. This all sounds really nice, and in theory, depending on your application and scalability planning, it could spare you MANY hours of developing (squeezing) database&#8230;<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"_links":{"self":[{"href":"https:\/\/www.nivas.hr\/blog\/wp-json\/wp\/v2\/posts\/219"}],"collection":[{"href":"https:\/\/www.nivas.hr\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nivas.hr\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nivas.hr\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nivas.hr\/blog\/wp-json\/wp\/v2\/comments?post=219"}],"version-history":[{"count":0,"href":"https:\/\/www.nivas.hr\/blog\/wp-json\/wp\/v2\/posts\/219\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.nivas.hr\/blog\/wp-json\/wp\/v2\/media?parent=219"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nivas.hr\/blog\/wp-json\/wp\/v2\/categories?post=219"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nivas.hr\/blog\/wp-json\/wp\/v2\/tags?post=219"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}