I've just recently set this up. There shouldn't be much work to be done.
In the mysqladapter gem it specifies the engine as InnoDB, which is obviously not suitable for clustering. You need to add this to an initialization file:
ActiveRecord::ConnectionAdapters::Mysql2Adapter
class ActiveRecord::ConnectionAdapters::Mysql2Adapter
def create_table(table_name, options = {})
super(table_name, options.reverse_merge(:options => "ENGINE=NDB"))
end
end
This is the original in the adapter.
def create_table(table_name, options = {})
super(table_name, options.reverse_merge(:options => "ENGINE=InnoDB"))
end
Another key aspect is you don't want migrations taking place at the same time so in the deploy.rb file:
task :migrate, :max_hosts => 1 do
# sleep 0.5
run "cd #{release_path} && bundle exec rake db:migrate RAILS_ENV=#{rails_env}"
end
Max hosts prevents cap from running the migrations in parallel. This is important as you don't want the cluster running create table type of things at the same time. It may even be worth putting a delay in I have commented above just for a little extra safety.
One more key aspect. Don't forget to set:
DataMemory =
IndexMemory =
The default values are supremely low. Typically index size is DataMemory/5-10
One more pitfall I've seen so far is in your mysqld nodes make sure you set:
ndb_autoincrement_prefetch_sz
to at least a 100. Otherwise bulk inserts will take forever. The default is 1.
EDIT:
ndb_autoincrement_prefetch_sz
Leave this variable completely alone. Don't set it. What it can cause is auto increment indexes to become out of sync on the cluster. Which is a nightmare to debug.
Additionally make sure you're NDB nodes don't run on the same server as the NDB MGM nodes.
Happy coding.
Ad