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