Sunday, June 20, 2010

Running MySQL Cluster as a Service on Windows

The MySQL Cluster daemon for MySQL Cluster (ndbd and ndb_mgmd) doesn't by themselves yet let them run as a service (apparently ndb_mgmd does, but I haven't seen it documented anywhere on how to do that). But there are ways to fix this, using some simple Windows tools and some registry hacking.

What you need to find is the Windows Resource Kit from some version of Windows that includes instsrv.exe and srvany.exe. It is not too picky with the actual version of Windows you run it seems, I used the Windows NT 32-bit versions of these on a 64-bit Windows 7 box, and it works just fine.

These two programs are simple and are easy to use:
  • instsrv allows you to install a service, it's real simple, just run the program and it will show the options (and these are few).
  • srvany allows you to run any odd program, that is not intended run as a service, do do this anyway.
Now, Google a bit and download these two puppies and open a DOS Window and change directory to where you installed these guys. Now we are realy to install three services (1 for the mgm and two datanodes), so they will run the srvany program:
F:>ResKit> instsrv mgm1 F:\ResKit\srvany.exe
F:>ResKit> instsrv ndbd1 F:\ResKit\srvany.exe
F:>ResKit> instsrv ndbd2 F:\ResKit\srvany.exe

These three services are rather boring now, they do not do anything, really. To fix this, open the registry editor (regedit) and open:
HKEY_LOCAL_MACHINE\System\CurrentControlset\services\mgm1
Now, we need to define what srvany.exe should run. In the key above, create a new key called Parameters. In this key then, create two values of the type REG_SZ:
  • Application - The full path to the program srvany should run.
  • AppParameters - The parameters to pass to the program srvany will run.
In my case, I set these to, for the mgm service:
Application: F:\MySQL714\bin\ndb_mgmd.exe
AppParams: --config-file=F:\MySQL714\mgm1\config.ini --configdir=F:\MySQL714\mgm1

I think you see where I'm going with this, but just to be sure, this is what I set for the ndbd1 service:
Application: F:\MySQL714\bin\ndbd.exe
AppParams: --ndb_connectstring=nodeid=2;host=localhost:1186

And that's it, folks! Well, one more thing I guess, we want to install the MySQL Server as a serive also, but this knows how to install itself as a service and can also run nicely as a service, so this is easy:
F:\ResKit>F:\MySQL714\bin\mysqld --install MySQL714 --defaults-file=F:\MySQL714\my.ini

Make sure that the ini-file for the MySQL server is configured to access the cluster we just set up, and to have the ndbcluster engine enabled (for some reason, the latter is not enabled by default). Do this by editing the my.ini file used by the server (and referenced above) and add the following two lines to the [mysqld] section:
ndb-connectstring=host=localhost:1186
ndbcluster

Now we have created and configured a bunch of services for a MySQL Cluster setup, and to try it out, lets start them using the NET command line program (the SC command may also be used):
F:\ResKit> net start mgm1
F:\ResKit> net start ndbd1
F:\ResKit> net start ndbd2
F:\ResKit> net start MySQL714

Have fun! And just a word of caution: Although this works just fine for testing, note that shutdown of the ndbd and mgm services isnt really graceful here, so this is just for fun and testing. Also, ndbd and ndb_mgmd will sure be possible to run as a Windows service in their own right, in some future version of MySQL Cluster.

/Karlsson

13 comments:

Jan said...

Hi,

you should check the "sc" (Service Control) command, as it can be used to create, delete and control service on Windows Systems out of the box.

Jan

Karlsson said...

True, but this still assumes that the prograns are services enabled. So the SC command could do away with instsrv and net, but not, as far as I can tell, srvany.

Unknown said...

I like to use MySQL Cluster daemon for MySQL Cluster service. I heard about this service that it is very good. Thanks a lot for sharing this information.



....Alex

online viagra

jack45 said...

I have wanted to learn more about particular topics, but not many websites would help me out in informing me the way I expected. This left me with many question, but after reading your article, I got an answer to all my questions. You are too cool dude!!!

valentines day ideas

Generic Viagra

jackanderson said...
This comment has been removed by the author.
Raffay said...

Wow Impressive! Your blog is very informative. However, it is pretty hard task but your post and experience serve and teach me how to handle and make it more simple and manageable.Thanks for the tips… Best regards.


cheap reseller hosting |
cpanel reseller

Josh said...

Vimax is reliable stuff to accomplish your sexual dysfunction. It has been proven by many men to augment virility and genital.

Jason Smith said...
This comment has been removed by the author.
Joshua said...

hey thanks for the information.. it has been of great use .. it updating more post..thanks..


regards..
astermeds.com

buy vicodin online said...

I have been looking for sites like this for a long time. Thank you! buy vicodin online

buy codeine online said...

I wanted to thank you for this great read.I am very pleased to find this site.
Thanks for sharing!
buy codeine online

Anonymous said...

i am also loving your blog for sharing fantastic topic thanks for sharing keep it up.



Free Classified Ads

saim said...

I like the valuable information you provide in your articles. I’ll bookmark your weblog and check again here frequently. I am quite sure I will learn many new stuff right here! Best of luck for the next!

best over the counter sleep aid