8.9.4 MySQL Fabric Configuration for Running Samples

To run JUnit tests from testsuite/fabric or demonstration examples from src/demo/fabric, you must configure the MySQL Fabric test environment as follows.

  1. Set up MySQL servers.

    • mysql-fabric-config: The backing store for Fabric configuration. Used internally by Fabric to store the server list, shard mappings, and so forth. You set up this server instance during the MySQL Fabric setup procedure.

    • mysql-global: The only server in the global group. Used to send DDL commands and update any data not in the shard data set.

      • Default location: 127.0.0.1:3401

      • Config properties: com.mysql.fabric.testsuite.global.host,

        com.mysql.fabric.testsuite.global.port

    • mysql-shard1: First shard of sharded data set

      • Default location: 127.0.0.1:3402

      • Config properties: com.mysql.fabric.testsuite.shard1.host,

        com.mysql.fabric.testsuite.shard1.port

    • mysql-shard2: Second shard of sharded data set

      • Default location: 127.0.0.1:3403

      • Config properties: com.mysql.fabric.testsuite.shard2.host,

        com.mysql.fabric.testsuite.shard2.port

    All except mysql-fabric-config should have server-id set to a distinct value and the following entries added to my.cnf:

    log-bin = mysql-bin
    log-slave-updates = true
    enforce-gtid-consistency = true
    gtid-mode = on
    
  2. Set up sharding. The user name and password of the account used to manage Fabric (Section 8.2.3.1, “Create a MySQL User”) must be specified in Fabric's configuration file (Section 8.2.3.2, “Configuration File”).

    • Create the global group:

      shell> mysqlfabric group create fabric_test1_global
      shell> mysqlfabric group add fabric_test1_global 127.0.0.1:3401
      shell> mysqlfabric group promote fabric_test1_global
      
    • Create shard groups:

      shell> mysqlfabric group create fabric_test1_shard1
      shell> mysqlfabric group add fabric_test1_shard1 127.0.0.1:3402
      shell> mysqlfabric group promote fabric_test1_shard1
      
      shell> mysqlfabric group create fabric_test1_shard2
      shell> mysqlfabric group add fabric_test1_shard2 127.0.0.1:3403
      shell> mysqlfabric group promote fabric_test1_shard2
      
    • Create the sharding definition:

      shell> mysqlfabric sharding create_definition RANGE fabric_test1_global
      

      Note the return value in the command output; for example, return = 1. This is the $MAPPING_ID used in the following commands

      shell> mysqlfabric sharding add_table $MAPPING_ID employees.employees emp_no
      
    • Create the shard index:

      shell> mysqlfabric sharding add_shard $MAPPING_ID \
        fabric_test1_shard1/0,fabric_test1_shard2/10000 --state=ENABLED