router - lefred/mysqlshell-plugins GitHub Wiki

router

This router module is different than other modules, it creates a router object that has itself some extra methods.

NAME
      router - MySQL Router Object

DESCRIPTION
      MySQL Router Object.

FUNCTIONS
      create(uri)
            Create the MySQL Router Object

      createRestUser([session])
            Create the MySQL Router REST API user in MySQL MetaData.

The router object uses MySQL Router's REST API to get the needed information.

For more information check the following post, the syntax is a bit different to create the router object:

methods

create

Create the MySQL Router Object

 JS  router=router.create("[email protected]:8080")
Password: ****
{
    "api": "20190715", 
    "connections": <Function:<lambda>>, 
    "status": <Function:<lambda>>
}

createRestUser

Create the MySQL Router REST API user in MySQL MetaData.

 JS  router.createRestUser()
You can now use 'clusteradmin' to authenticate to MySQL Router's REST API.
Use myrouter=router.create() to create an object to monitor.

SYNTAX
      router.createRestUser([session])

WHERE
      session: Object. The optional session object used to query the database.
               If omitted the MySQL Shell's current session will be used.

router object

methods

connections

Prints information about the connections on different routes such the source and the destination

 JS  router.connections()
+------------------------+------------------------+--------------+----------------------+----------------------+-----------------------------+
| Route                  | Source                 | Destination  |          From Server |            To Server | Connection Started          |
+------------------------+------------------------+--------------+----------------------+----------------------+-----------------------------+
| myCluster_ro           |                        |              |                      |                      |                             |
| myCluster_rw           | 192.168.242.1:54578    | mysql1:3306  |                 3 kb |            812 bytes | 2020-08-01T09:46:13.013180Z |
| myCluster_x_ro         |                        |              |                      |                      |                             |
| myCluster_x_rw         |                        |              |                      |                      |                             |
+------------------------+------------------------+--------------+----------------------+----------------------+-----------------------------+

status

Prints status information related to MySQL Router.

 JS  router.status()
+-------------------------+
| Cluster name: myCluster |
+-------------------------+
     Refresh Succeeded: 164
        Refresh Failed: 0
 Last Refresh Hostname: mysql2:3306
   +--------+
   | routes |
   +--------+
    * myCluster_ro (alive) :
	Total Connections: 0	Active Connections: 0	Blocked Hosts: 0
	---> mysql2 : 3306
	---> mysql3 : 3306
    * myCluster_rw (alive) :
	Total Connections: 1	Active Connections: 1	Blocked Hosts: 0
	---> mysql1 : 3306
    * myCluster_x_ro (alive) :
	Total Connections: 0	Active Connections: 0	Blocked Hosts: 0
	---> mysql2 : 33060
	---> mysql3 : 33060
    * myCluster_x_rw (alive) :
	Total Connections: 0	Active Connections: 0	Blocked Hosts: 0
	---> mysql1 : 33060
⚠️ **GitHub.com Fallback** ⚠️