Code Monkey home page Code Monkey logo

proxysql-orchestrator-sync's Introduction

proxysql-orchestrator-sync

Synchronize MySQL master and slave data from GitHub Orchestrator's API into ProxySQL.

When nodes fail, GitHub Orchestrator will mark these nodes as down. The synchronization script will remove failed nodes from its rotation.

How does it work?

This PHP script will poll the Orchestrator API at regular intervals and compare the state of the nodes to what is known in ProxySQL.

If the state differs, the ProxySQL servers will be flushed and re-populated with Orchestrator data.

The /api/cluster/alias/yourClusterName endpoint is used as the "source of truth". This API call returns a collection of JSON objects, where each object represents a server.

The following object properties are used in the decision making process:

  • IsDowntimed: is the server deliberately put in downtime?
  • IsLastCheckValid: did the server pass its last health check?

And specifically for slave servers, the following properties are used:

  • Slave_SQL_Running: is the SQL replication mechanism running on a slave?
  • Slave_IO_Running: is the I/O replication mechanism running on a slave?

If a server doesn't meet the assertions above, it is not taken into rotation and will not be inserted in ProxySQL upon the next synchronisation run.

When will the script perform a synchronization run?

The pollInterval configuration item defines the frequency of the runs in seconds. By default this is 10 seconds.

However, this script also offers a webhook that explicitly forces a re-population of the ProxySQL servers. By default the scripts binds to port 8080 on all network interfaces, but the binding can be configured in the binding configuration item.

Why, where and when to use the webhook?

The webhook was specifically built to be called by the Orchestrator hooks.

In your orchestrator.conf.json file, you could for example add the following call:

...
{
 "PostFailoverProcesses": [
   "curl -s http://proxy-sync-host:8080/"
 ],
}
...

After a failover, you can force the synchronization script to run, but calling the webhook. You can also perform this call in the PreFailoverProcesses hook.

proxysql-orchestrator-sync's People

Contributors

thijsferyn avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.