This topic describes how to use the MySQL proxy to monitor the health of your MySQL instance.
If you cannot write or connect to your app, you should check the health status of your MySQL VMs. You can observe the health status of MySQL VMs through a proxy using the Switchboard dashboard or API endpoint. You can also view the number of client connections routed through a proxy to each VM.
Ops Manager uses a proxy to send client connections to the healthy MySQL database cluster nodes in a highly available cluster plan. Using a proxy gracefully handles failure of nodes, enabling fast, failover to other nodes within the cluster. When a node becomes unhealthy, the proxy closes all connections to the unhealthy node and re-routes all subsequent connections to a healthy node.
The proxy used in TAS for VMs is Switchboard. Switchboard was developed to replace HAProxy as the proxy tier for the high availability cluster for MySQL databases in TAS for VMs.
Switchboard offers the following features:
MySQL Server Access
MySQL clients communicate with nodes through this network port. These connections are automatically passed through to the nodes.
Switchboard and API
Operators can connect to Switchboard to view the state of the nodes.
When determining where to route traffic, the proxy queries an HTTP health check process running on the node. This health check can return as either healthy or unhealthy, or the node can be unresponsive.
If the health check process returns HTTP status code 200
, the proxy includes the node in its pool of healthy nodes.
When a new or resurrected nodes rejoin the cluster, the proxy continues to route all connections to the currently active node. In the case of failover, the proxy considers all healthy nodes as candidates for new connections.
If the health check returns HTTP status code 503
, the proxy considers the node unhealthy.
This happens when a node becomes non-primary. For more information, see About Multi-Site replication.
The proxy severs existing connections to newly unhealthy node. The proxy routes new connections to a healthy node, assuming such a node exists. Clients are expected to handle reconnecting on connection failure should the entire cluster become inaccessible.
If node health cannot be determined due to an unreachable or unresponsive health check endpoint, the proxy considers the node unhealthy. This may happen if there is a network partition or if the VM running the node and healthcheck died.
You can monitor the health status of your nodes by doing one of the following:
Each MySQL Proxy instance has its own Switchboard dashboard. To access the dashboard, you must construct the dashboard URL.
To construct the URL for the Switchboard dashboard:
Find and record the system domain on the Domains pane in the TAS for VMs tile.
Find and record the number of MySQL Proxy VM instances in your deployment in the Resource Config pane.
Use the above information to build the Switchboard dashboard URL as follows: https://[PROXY-VM-INDEX]-proxy-p-mysql-ert.[SYSTEM-DOMAIN]
To log into the Switchboard dashboard:
In the TAS for VMs tile, the URL in your browser contains the Ops Manager fully qualified domain name (FQDN) and the TAS for VMs product GUID, as in the following example: https://OPS-MANAGER-FQDN/products/APPLICTION-SERVICE-PRODUCT-GUID/az_and_network_assignments/edit
To log into the dashboard, you need the username and password for the MySQL Proxy VM that are stored in the BOSH Director CredHub.
To obtain them, enter https://[OPS-MANAGER-FQDN]/api/v0/deployed/products/[APPLICTION-SERVICE-PRODUCT-GUID]/variables?name=mysql-proxy-dashboard-credentials
into your browser and record the username and password.
Enter the dashboard URL you constructed into your browser and log in using the credentials you obtained in Construct the URL for the Dashboard.
To monitor node health using the Switchboard dashboard:
To view a list of proxies in your browser, navigate to the URL that you created in Construct the URL for the Dashboard.
When prompted, enter the username and password that you recorded in Log In to the Dashboard.
Click the link for the proxy that you want to use to monitor node health.
If you are prompted, enter the username and password that you recorded in Log In to the Dashboard.
You can also use the Switchboard API to obtain the information that is shown on the Switchboard dashboard. For example, you might want to use the API to write your own app to monitor the cluster.
To monitor node health using the Switchboard API:
To monitor node health, run:
curl https://USERNAME:PASSWORD@N-HOSTNAME/v0/backends
Where:
USERNAME
is the username
you recorded in Log In to the Dashboard.PASSWORD
is the password
you recorded in Log In to the Dashboard.N
is either 0, 1, or 2 depending on the proxy you want to connect to.HOSTNAME
is the IP address of the Database found in the Status tab of your TAS for VMs tile.The above command outputs a JSON object similar to:
$ curl https://abcdefghijklmno:012345678912345@0-proxy.123abc45-67d8-912e-34f5-g34612c10dba.org.dedicated-mysql.cf-app.com/v0/backends [ { "host": "a-b1234c5d6.e-f891.bosh", "port": 6033, "healthy": true, "name": "backend-0", "currentSessionCount": 0, "active": true, "trafficEnabled": true }, { "host": "a-b1234c5d6.e-f891.bosh", "port": 6033, "healthy": true, "name": "backend-1", "currentSessionCount": 0, "active": false, "trafficEnabled": true }, { "host": "a-b1234c5d6.e-f891.bosh", "port": 6033, "healthy": true, "name": "backend-2", "currentSessionCount": 0, "active": false, "trafficEnabled": true } ]