Skip to content

Instantly share code, notes, and snippets.

@adbrsln
Last active April 5, 2022 05:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adbrsln/ccc5c8aa4bb9166b68e5fa1672719fe7 to your computer and use it in GitHub Desktop.
Save adbrsln/ccc5c8aa4bb9166b68e5fa1672719fe7 to your computer and use it in GitHub Desktop.
Multiple MySQL Router Client (Different Cluster) on Single Server

Introductions

Planning to connect to multiple Cluster at once from a single server? heres the plan...

  • Cluster 1
    • c1-node-1
    • c1-node-2
    • c1-node-3
  • Cluster 2
    • c2-node-1
    • c2-node-2
    • c2-node-3
  • Cluster 3
    • c3-node-1
    • c3-node-2
    • c3-node-3

Prerequisite

  • install the mysqlrouter as usual
  • do not bootstrap anything yet
  • set your /etc/hosts files containing all the relevant servers
  • always set different base port so it doesnt clash to each other
  • always set different https port so it doesnt clash to each other

Installation

  • run the command for bootstrapping the servers

    ##boostrap the Cluster 1
    
    $> mysqlrouter --boostrap <boostrap-user>@<c1-node-1> -d <c1-conf-directory> --user=mysqlrouter --conf-base-port=6446 --https-port=18443
    
    
    ##boostrap the Cluster 2
    
    $> mysqlrouter --boostrap <boostrap-user>@<c1-node-2> -d <c2-conf-directory> --user=mysqlrouter --conf-base-port=7446 --https-port=28443
    
    
    ##boostrap the Cluster 3
    
    $> mysqlrouter --boostrap <boostrap-user>@<c1-node-3> -d <c3-conf-directory> --user=mysqlrouter --conf-base-port=8446 --https-port=38443
    
  • once the boostrap is done, you can start using the nohup command to make it run on the background

    $> nohup mysqlrouter -c <c1-config-directory> &
    $> nohup mysqlrouter -c <c2-config-directory> &
    $> nohup mysqlrouter -c <c3-config-directory> &
    
  • to check your setup is working just check the ps command

    ps -ef | grep mysqlrouter
    
  • the command above should show 3 of the instances of mysqlrouter processes has been successfully started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment