MySQL Router 2.1  /  General Information  /  Connection Routing

1.3 Connection Routing

Connection routing enables redirection of MySQL connections to an available MySQL server. MySQL packets are routed in their entirety without inspection.

This means you can set up your application to connect to MySQL Router, and retry the connection if the current MySQL server fails as Router then selects a new MySQL server to redirect the connection to. This is also called simple redirect connection routing because it requires the application to retry the connection. That is, if a connection from MySQL Router to the MySQL server is interrupted, the application encounters a connection failure. However, a new connection attempt triggers Router to find and connect to another MySQL server.

Routed servers and routing strategies are defined in a configuration file. For example, the following section tells the router to listen for connections on port 7002 of the localhost, and then redirect those connections to any of the servers in the list named by the destinations option, including servers running on the localhost listening on ports 3306, 3307, and 3308. Finally, we use the mode option to tell the router to allow both readers and writers. For more information about the available modes, see the section entitled, Configuration File Setup below.

bind_port = 7002
mode = read-write
destinations = localhost:3306,localhost:3307,localhost:3308

Notice that the section is entitled, routing:simple_redirect. The first part, routing is called the section name and is used internally to determine which plugin to load. The last part is an option's section key (name) you can optionally provide should you want to set up more than one routing strategy.

When a server is no longer reachable, MySQL Router moves to the next server destination in the list, and halts redirection if the list is exhausted because this is the default mode schedule when the mode option is set to read-write.

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