Installing MySQL Fabric on Windows

One of the major announcements made at the MySQL Connect conference just over a week ago was the labs release of MySQL Fabric, which supports management of MySQL Server farms in a sharded deployment.  It’s available on labs.mysql.com, which means it is just an early release with some rough edges.  One of those rough edges that I’d like to see resolved soon is that it’s difficult to install on Windows, as there is no installer package provided.  There is some documentation on how to install Fabric (you’ll find it in section 15.8.2 of the PDF that makes up the downloadable documentation), but it’s focused on Linux platforms, so I thought I would post the process that got Fabric installed on my Windows 7 machine, for other Windows users who want to play with Fabric.  Here are the steps:

1.  Download and install Python 2.7

I used Python 2.7.5, found here.

2.  Download and unzip MySQL Fabric

The .ZIP package is found here on labs.mysql.com.  Simply unzip it to the path of your choosing.

3.  Modify setup.py

I tried to run “setup.py install” as described in the docs, but it failed for me.  I reported this as Bug#70512, but it seems like the solution is simply to comment out the last line in the below code snippet:

        if os.name == 'posix' and install_dir in ('/', '/usr'):
            install_sysconfdir = '/etc'
        else:
            install_sysconfdir = os.path.join(install_dir, 'etc')
        # install_sysconfdir = '/etc'

Save the file once that last definition of install_sysconfdir is commented out.

4.  Run setup.py install

Using the command line, go to the directory where you unzipped MySQL Fabric and run “python setup.py install”.  You may need to provide the full path to the python.exe executable:

D:\>cd mysql-utilities-1.4.0

D:\mysql-utilities-1.4.0>c:\Python27\python.exe setup.py install
checking mysql for packages to distribute
packages found: ['mysql', 'mysql.connector', 'mysql.connector.locales', 'mysql.c
onnector.locales.eng', 'mysql.fabric', 'mysql.fabric.protocols', 'mysql.fabric.s
ervices', 'mysql.utilities', 'mysql.utilities.command', 'mysql.utilities.common'
]
scripts found: ['scripts\\mysqlauditadmin.py', 'scripts\\mysqlauditgrep.py', 'sc
ripts\\mysqldbcompare.py', 'scripts\\mysqldbcopy.py', 'scripts\\mysqldbexport.py
', 'scripts\\mysqldbimport.py', 'scripts\\mysqldiff.py', 'scripts\\mysqldiskusag
e.py', 'scripts\\mysqlfabric.py', 'scripts\\mysqlfailover.py', 'scripts\\mysqlfr
m.py', 'scripts\\mysqlindexcheck.py', 'scripts\\mysqlmetagrep.py', 'scripts\\mys
qlprocgrep.py', 'scripts\\mysqlreplicate.py', 'scripts\\mysqlrpladmin.py', 'scri
pts\\mysqlrplcheck.py', 'scripts\\mysqlrplshow.py', 'scripts\\mysqlserverclone.p
y', 'scripts\\mysqlserverinfo.py', 'scripts\\mysqluc.py', 'scripts\\mysqluserclo
ne.py']
package set set(['mysql.utilities.command', 'mysql.utilities.common', 'mysql.fab
ric', 'mysql.fabric.protocols', 'mysql.fabric.services', 'mysql.connector.locale
s', 'mysql.connector', 'mysql.utilities', 'mysql', 'mysql.connector.locales.eng'
])
running install
running build
running build_py
running build_scripts
running install_lib
running install_scripts
running install_data
copying data\fabric.cfg -> c:\Python27\data
copying data\fabric.cfg -> c:\Python27\etc\mysql
running install_egg_info
Removing c:\Python27\Lib\site-packages\mysql_utilities-1.4.0-py2.7.egg-info
Writing c:\Python27\Lib\site-packages\mysql_utilities-1.4.0-py2.7.egg-info

D:\mysql-utilities-1.4.0>

5.  Set Fabric configuration file

Because of the change we made in the setup.py script, Fabric will look for a configuration file at etc\mysql\fabric.cfg under the Fabric installation directory.  There is a template to be found at data\fabric.cnf; take this and modify it according to your needs.  Here’s what mine looks like:

[DEFAULT]
prefix = 
sysconfdir = c:\Python27\etc
logdir = D:\logs

[storage]
address = localhost:3306
user = fabric
password = fabric
database = fabric
connection_timeout = 6

[protocol.xmlrpc]
address = localhost:8080
threads = 5

[executor]
executors = 5

[logging]
level = INFO
url = D:\mysql-utilities-1.4.0\log\fabric.log

[sharding]
mysqldump_program = D:\mysql-5.6.13-winx64\bin\mysqldump.exe
mysqlclient_program = D:\mysql-5.6.13-winx64\bin\mysql.exe

[connector]
ttl = 1

6. Create MySQL Server fabric schema

Fabric uses a MySQL Server as a data store on the back-end; you’ll need to create a schema for fabric to use.  Obviously, if you don’t have MySQL Server installed, you’ll need to do so first, and then create the schema, making sure the name matches the database defined in the configuration file in step 5:

mysql> create database fabric;

Query OK, 1 row affected (0.01 sec)

7. Create the MySQL Server fabric user account

Fabric also requires credentials to access the MySQL Server it is using as a repository; in step #5, I used “fabric” as both the user name and password.  Create the user account and grant appropriate privileges like below:

mysql> CREATE USER fabric@localhost IDENTIFIED BY 'fabric';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL ON fabric.* TO fabric@localhost;
Query OK, 0 rows affected (0.00 sec)

7. Testing

At this point, you should have a working MySQL Fabric installation.  There’s still much documentation to be done around the various Fabric commands and how to work with the Fabric server, so the command I find most useful is “list-commands”:

D:\mysql-utilities-1.4.0>scripts\mysqlfabric.py list-commands
group activate                   Activate a group.
group import_topology            Try to figure out the replication topology and
import it into the state store.
group deactivate                 Deactivate a group.
group create                     Create a group.
group remove                     Remove a server from a group.
group add                        Add a server into group.
group lookup_servers             Return information on existing server(s) in a g
roup.
group check_group_availability   Check if any server within a group has failed a
nd report health information.
group destroy                    Remove a group.
group demote                     Demote the current master if there is one.
group promote                    Promote a server into master.
group lookup_groups              Return information on existing group(s).
group description                Update group's description.
manage list-commands             List the possible commands.
manage help                      Give help on a command.
manage lookup_fabrics            Return a list of Fabric servers.
manage teardown                  Teardown Fabric Storage System.
manage stop                      Stop the Fabric server.
manage setup                     Setup Fabric Storage System.
manage ping                      Check whether Fabric server is running or not.
manage start                     Start the Fabric server.
manage logging_level             Set logging level.
server lookup_uuid               Return server's uuid.
server set_status                Set a server's status.
sharding move                    Move the shard represented by the shard_id to t
he destination group.
sharding lookup_servers          Lookup a shard based on the give sharding key.
sharding disable_shard           Disable a shard.
sharding remove_mapping          Remove the shard mapping represented by the Sha
rd Mapping object.
sharding list_mappings           Returns all the shard mappings of a particular
sharding_type.
sharding add_mapping             Add a table to a shard mapping.
sharding add_shard               Add a shard.
sharding list_definitions        Lists all the shard mapping definitions.
sharding enable_shard            Enable a shard.
sharding remove_shard            Remove a Shard.
sharding prune_shard             Given the table name prune the tables according
to the defined sharding specification for the table.
sharding lookup_mapping          Fetch the shard specification mapping for the g
iven table
sharding split                   Split the shard represented by the shard_id int
o the destination group.
sharding define                  Define a shard mapping.
event trigger                    Trigger an event.
event wait_for_procedures        Wait until procedures, which are identified thr
ough their uuid in a list and separated by comma, finish their execution.
store dump_shard_tables          Return information about all tables belonging t
o mappings matching any of the provided patterns.
store dump_sharding_information  Return all the sharding information about the t
ables passed as patterns.
store dump_shard_maps            Return information about all shard mappings mat
ching any of the provided patterns.
store dump_shard_index           Return information about the index for all mapp
ings matching any of the patterns provided.
store dump_servers               Return information about all servers.

D:\mysql-utilities-1.4.0>

I hope other Windows users may find the above information useful.

2 thoughts on “Installing MySQL Fabric on Windows

  1. Hi,

    How to setup admin password for mysqlfabric. I have executed the above steps and suucessfully executed all the above steps. Now i need to create a group . It asked to me to provide admin password

    Please help me

    1. Hello Aneesha,

      I believe this may be a request for the account on the managed MySQL Server nodes that can be used by Fabric for management operations. That is typically part of the Fabric configuration file:

      Fabric accesses each added server using the user and password provided in the configuration file to guarantee that they are alive and accessible. If these requirements are not fulfilled, the operation fails and the server is not added to the group.

      A good place to look for assistance if you continue to have problems is the Fabric user forum, where more knowledgeable Fabric developers often answer user questions.

      I hope that helps!

Leave a Reply to Todd Farmer Cancel reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.