DEV Community

Muhammad Adib Ahmad Roslan
Muhammad Adib Ahmad Roslan

Posted on

Multiple MySQL Router Client in Single Server/Nodes

Introductions

High-level architecture of your application

As shown as example of above architecture diagram, your application servers require to connect to 3 different InnoDB MySQL Cluster.

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

  • MySQL InnoDB Cluster 1
    • c1-node-1
    • c1-node-2
    • c1-node-3
  • MySQL InnoDB Cluster 2
    • c2-node-1
    • c2-node-2
    • c2-node-3
  • MySQL InnoDB 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

Configuration

  • 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
Enter fullscreen mode Exit fullscreen mode
  • 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> &
Enter fullscreen mode Exit fullscreen mode
  • to check your setup is working just check the ps command
  ps -ef | grep mysqlrouter
Enter fullscreen mode Exit fullscreen mode
  • the command above should show 3 of the instances of mysqlrouter processes has been successfully started.

Thats All, Thanks for reading!

Top comments (0)