Documentation Home
MySQL Utilities 1.5 Manual
Related Documentation Download this Manual
PDF (US Ltr) - 1.5Mb
PDF (A4) - 1.5Mb
HTML Download (TGZ) - 289.5Kb
HTML Download (Zip) - 301.7Kb


MySQL Utilities 1.5 Manual  /  ...  /  Sharding Commands

8.4.9 Sharding Commands

The sharding commands are used to define, modify, and control sharding.

  • Command: add_shard: Add a shard.

    Usage:
      mysqlfabric  sharding add_shard <shard_mapping_id> <groupid_lb_list>      
                   [--state=DISABLED] [--update_only] [--synchronous]           
    Parameters:
      <shard_mapping_id>  The unique identification for a shard mapping.        
      <groupid_lb_list>   The list of group_id, lower_bounds pairs in the format,
                          group_id/lower_bound, group_id/lower_bound...         
    
    Options:
      --state=STATE  Indicates whether a given shard is ENABLED or DISABLED. By 
                     default DISABLED.                                          
      --update_only=UPDATE_ONLY                                                 
                     Only update the state store and skip adding range checks. By
                     default False.                                             
      --synchronous=SYNCHRONOUS                                                 
                     Whether one should wait until the execution finishes or not.
                     By default True.                                           
    
    Return:
      A dictionary representing the current Range specification.
    
  • Command: add_table: Add a table to a shard mapping.

    Usage:
      mysqlfabric  sharding add_table <shard_mapping_id> <table_name>           
                   <column_name> [--range_check] [--update_only] [--synchronous]
    
    Parameters:
      <shard_mapping_id>  The shard mapping id to which the input table is      
                          attached.                                             
      <table_name>        The table being sharded.                              
      <column_name>       The column whose value is used in the sharding scheme 
                          being applied                                         
    
    Options:
      --range_check=RANGE_CHECK                                                 
                Indicates if range check should be turned on for this table. By 
                default False.                                                  
      --update_only=UPDATE_ONLY                                                 
                Only update the state store and skip adding range checks. By    
                default False.                                                  
      --synchronous=SYNCHRONOUS                                                 
                Whether one should wait until the execution finishes or not. By 
                default True.                                                   
    
  • Command: create_definition: Define a shard mapping.

    Usage:
      mysqlfabric  sharding create_definition <type_name> <group_id>            
                   [--synchronous]                                              
    
    Parameters:
      <type_name>  The type of sharding scheme - RANGE or HASH          
      <group_id>   Every shard mapping is associated with a global group that   
                   stores the global updates and the schema changes for this shard
                   mapping and dissipates these to the shards.                  
    
    Options:
      --synchronous=SYNCHRONOUS                                                 
                Whether one should wait until the execution finishes or not. By 
                default True.                                                   
    
  • Command: disable_shard: Disable a shard.

    Usage:
      mysqlfabric  sharding disable_shard <shard_id> [--synchronous]            
    
    Parameters:
      <shard_id>  The shard ID of the shard that needs to be removed.           
    
    Options:
      --synchronous=SYNCHRONOUS                                                 
                Whether one should wait until the execution finishes or not. By 
                default True.                                                   
    
  • Command: enable_shard: Enable a shard.

    Usage:
      mysqlfabric  sharding enable_shard <shard_id> [--synchronous]             
    
    Parameters:
      <shard_id>  The shard ID of the shard that needs to be removed.           
    
    Options:
      --synchronous=SYNCHRONOUS                                                 
                Whether one should wait until the execution finishes or not. By 
                default True.                                                   
    
  • Command: list_definitions: Lists all the shard mapping definitions.

    Usage:
      mysqlfabric  sharding list_definitions                                    
    
    Return:
      A list of shard mapping definitions An Empty List if no shard mapping
      definition is found.
    
  • Command: list_tables: Returns all the shard mappings of a particular sharding_type

    Usage:
      mysqlfabric  sharding list_tables <sharding_type>                         
    
    Parameters:
      <sharding_type>  The sharding type for which the sharding specification   
                       needs to be returned.                                    
    
    Return:
      A list of dictionaries of shard mappings that are of the sharding type An
      empty list of the sharding type is valid but no shard mapping definition is
      found An error if the sharding type is invalid.
    
  • Command: lookup_servers: Lookup a shard based on the give sharding key.

    Usage:
      mysqlfabric  sharding lookup_servers <table_name> <key> [--hint=LOCAL]    
    
    Parameters:
      <table_name>  The table whose sharding specification needs to be looked up.
      <key>         The key value that needs to be looked up                    
    
    Options:
      --hint=HINT  A hint indicates if the query is LOCAL or GLOBAL. By default 
                   LOCAL.                                                       
    
    Return:
      The Group UUID that contains the range in which the key belongs.
    
  • Command: lookup_table: Fetch the shard specification mapping for the given table.

    Usage:
      mysqlfabric  sharding lookup_table <table_name>                           
    
    Parameters:
      <table_name>  The name of the table for which the sharding specification is
                    being queried.                                              
    
    Return:
      The a dictionary that contains the shard mapping information for the given
      table.
    
  • Command: move_shard: Move the shard represented by the shard_id to the destination group.

    By default this operation takes a backup, restores it on the destination group and guarantees that source and destination groups are synchronized before pointing the shard to the new group. If users just want to update the state store and skip these provisioning steps, the update_only parameter must be set to true.

    Usage:
      mysqlfabric  sharding move_shard <shard_id> <group_id> [--update_only]    
                   [--synchronous]                                              
    
    Parameters:
      <shard_id>  The ID of the shard that needs to be moved.                   
      <group_id>  The ID of the group to which the shard needs to be moved.     
    
    Options:
      --update_only=UPDATE_ONLY                                                 
                By default False.                                               
      --synchronous=SYNCHRONOUS                                                 
                Whether one should wait until the execution finishes or not. By 
                default True.                                                   
    
  • Command: prune_shard: Given the table name prune the tables according to the defined sharding specification for the table.

    Usage:
      mysqlfabric  sharding prune_shard <table_name> [--synchronous]            
    
    Parameters:
      <table_name>  The table that needs to be sharded.                         
    
    Options:
      --synchronous=SYNCHRONOUS                                                 
                Whether one should wait until the execution finishes or not. By 
                default True.                                                   
    
  • Command: remove_definition: Remove the shard mapping definition represented by the Shard Mapping ID.

    Usage:
      mysqlfabric  sharding remove_definition <shard_mapping_id> [--synchronous]
    
    Parameters:
      <shard_mapping_id>  The shard mapping ID of the shard mapping definition  
                          that needs to be removed.                             
    
    Options:
      --synchronous=SYNCHRONOUS                                                 
                Whether one should wait until the execution finishes or not. By 
                default True.                                                   
    
  • Command: remove_shard: Remove a shard.

    Usage:
      mysqlfabric  sharding remove_shard <shard_id> [--synchronous]             
    
    Parameters:
      <shard_id>  The shard ID of the shard that needs to be removed.           
    
    Options:
      --synchronous=SYNCHRONOUS                                                 
                Whether one should wait until the execution finishes or not. By 
                default True.                                                   
    
  • Command: remove_table: Remove the shard mapping represented by the Shard Mapping object.

    Usage:
      mysqlfabric  sharding remove_table <table_name> [--synchronous]           
    
    Parameters:
      <table_name>  The name of the table whose sharding specification is being 
                    removed.                                                    
    
    Options:
      --synchronous=SYNCHRONOUS                                                 
                Whether one should wait until the execution finishes or not. By 
                default True.                                                   
    
  • Command: split_shard: Split the shard represented by the shard_id into the destination group.

    By default this operation takes a backup, restores it on the destination group and guarantees that source and destination groups are synchronized before pointing the shard to the new group. If users just want to update the state store and skip these provisioning steps, the update_only parameter must be set to true.

    Usage:
      mysqlfabric  sharding split_shard <shard_id> <group_id>                   
                   [--split_value=SPLIT_VALUE] [--update_only] [--synchronous]  
    
    Parameters:
      <shard_id>  The shard_id of the shard that needs to be split.             
      <group_id>  The ID of the group into which the split data needs to be moved.
    
    Options:
      --split_value=SPLIT_VALUE                                                 
                The value at which the range needs to be split. By default None.
      --update_only=UPDATE_ONLY                                                 
                By default False.                                               
      --synchronous=SYNCHRONOUS                                                 
                Whether one should wait until the execution finishes. By default
                True.                                                           
    

User Comments
Sign Up Login You must be logged in to post a comment.