Detection of outdated replicas at mysql router - mysql

I am using mysqlrouter to route traffic to InnoDB cluster nodes with master-slave replication (1 master + 2 slaves). For some reason, I am frequently facing replication issues and seeing that replicas don't have data for the last 2 hours.
As a result, application, which uses Read-Only nodes has incorrect data. Is it possible for mysqlrouter to detect replicas, which are not in-sync and not to route traffic there?

I don't believe that MySQL Router as such option. MySQL Router is more focused in Group Replication.
Maybe you could consider tuning up your replication to reduce the delay.
But if you need such functionality you can look up for ProxySQL. It is an alternative to MySQL Router.
You can read more about the functionality in their documentation.

I don't think so mysql router has anything to do with replication:

Related

Can I implement synchronous and asynchronous replication with the MySQL cluster?

I want to do synchronous and asynchronous replication, synchronize for some databases, and asynchrony for others.
Asynchronous I am doing it through MariaDB, through the traditional system that has replication.
But I want to implement synchronous replication also with Mysql / MariaDB.
The problem is that I do not know if Mysql Cluster also does that work, or if it is not necessary to have Mysql installed only or MariaDb and only use Mysql Cluster for both.
Thank you.
Disclosure: I am working for the MySQL Cluster team - "MySQL Cluster" as in NDB Cluster.
MySQL NDB Cluster always uses synchronous replication between its nodes. You can still use asynchronous replication to other MySQL instances or MySQL Clusters.
AFAIK only MySQL offers NDB and as open source.
Due to the usual network limitations synchronous replication is better suited for high availability in the local data center. It gives you an always consistent view of your data, two or more active instances and makes programing against it much easier.
Asynchronous is more for replication between data centers or availability zones where you can live with temporary inconsistencies in the data and have your programming model set up accordingly.
"MySQL Cluster" has more than one meaning, so I will avoid it.
"Galera" is the underlying cluster technology in MariaDB, PXC, and (if you do the installation yourself), MySQL.
Galera provides essentially-synchronous among (typically) 3 nodes. Meanwhile, each node can have any number of asynchronous Slaves hanging off it.
Also, one Galera cluster can asynchronously replicate to another such cluster. This is sometimes done with a cluster in each of two datacenters.
Mixing sync and async at the database level is quite unusual, and seems strange. The general principle of Replication is that all servers will have exactly the same (barring delays) data. Please elaborate on what you want to do. Also, think out of the box when it comes to topologies.

mysql multi-source replication stability

We use mysql multi-source replication, analysts and developers works with the databases, it's a main task of server(cross-bases queries, etc). Mysql slave replicates data from about 10-15 servers, some of them is realy big (400gb, 500gb, 1.5tb). Slave host - ec2 r4.2xlarge. But have some problems, main of them - stability. Often there is an errors 1236, 1594. We fix one channel - another fails, sometimes it's critical.
Backups of most master databases are performed through ebs snapshot, where datadir located. But here another problem of mysql multi-source - work with backups, unlike multi instance replication, I can not just change datadir, where backup located.
I was trying to find a solution that at least partially solved the problems of stability and work with snapshots, but I found absolutely nothing.
Did I understand correctly that there is no support for multi-source replication in the aws-RDS?
Maybe there is a similar solution, or there is another approach to solving the problem (FEDERATED is bad variant). Thanks for any help and advices.
As Michael said, you shouldn't be encountering these errors. Multi source replication has quite stable now. I personally been using it for more than 2 years now. Yes I have faced some of issues like "slave trying to access binlogs that master has purged", but most of them were easy to sort out. I would recommend you to look at these replication topics:
Errant transactions
GTID hole : this was there because of bug
max allowed packet error
We fix one channel - another fails, sometimes it's critical.
make sure you're not touching GTID set for other channels.
Did I understand correctly that there is no support for multi-source
replication in the aws-RDS?
The feature still not available in any of AWS cloud services. https://forums.aws.amazon.com/thread.jspa?messageID=781416&tstart=0
Multi source replication is not supported in RDS , you can use AWS DMS for same purpose .

HAProxy for MySQL Master Slave Repliation

I need some advice on setting up HAProxy for MySQL master-slave replication cluster: I want all connections i.e. all reads and writes to go to the master and only if the Master fails should HAProxy forward the connections to the slave.
The HAProxy documentation isn't very clear on which balancing algorithm to use for this scenario. The way I figure it, using static-rr with very high weights for the master and the lowest weights for the slave is the closest I can get to configuring the scenario described above. But there is still a small chance that the slave gets the reads/writes even though the master is still up and healthy?
Which is the correct way to setup HAProxy for this strict master/slave setup? Is HAProxy the right tool to use or is there a better way to achieve this?
Use MaxScale from MariaDB. It is a real DB router. Easy to use and easy to configure. Is direct for MySQL/MariaDB or Galera Cluster.
If you have more question we can chat
There's a similar question on stackoverflow with a description of how to use a custom health check to force HAProxy to send all traffic to the master, falling back to the read-only slaves if it fails.

Master/Slave replication load balancing if master down with Galera

I'm kind of lost there, I want to setup a common MASTER/SLAVE replication on a MariaDB database. I choose MASTER/SLAVE over MASTER/MASTER to avoid complexifying things. The SLAVE will be used only if the MASTER server is down.
I've setup MariaDB 10.0.x, but when I start reading on how to achieve this replication, they introduce Galera, which, if I understand correctly, replaces MariaDB.
What do you use to tell the SLAVE server to take the relay if the MASTER server is down ? Is it handled automatically via the Galera Cluster ?
If possible, I don't want my application to be aware of the slave server : I just want to configure it with the IP of MariaDB MASTER, and if it can't be reached, to use the SLAVE instead. (But I do not want to specify this fallback in the application level)
Thanks
What you are looking for can be achieved. I just completed a setup of MariaDB 10 using asynchronous replication (not Galera). To ensure maximum uptime I setup master / master replication and used mysql-mmm to monitor the setup. This tool will manage a virtual IP and point it at one of the two masters for writing purposes. This ensures consistent writes against a single master as to avoid corruption of the data. If one master fails the virtual IP will be mapped to the other master. This provides the high availability aspect. The instructions stated below were very clear and easy to follow.
http://mysql-mmm.org/mmm2:guide
Good luck!

proxy in front of mysql for redundancy removal

I'm trying to implement a proxy layer in front of MySQL server, that will catch redundant SQL queries and send them only once to the server. In other words, I have many clients (in PHP, Perl, on different web nodes) that talk to the MySQL and very often repeat the same SELECT queries. When traffic goes up MySQL, very often, goes down.
The question is - are you aware of any open source (or commercial) tool that can help? I tried MySQL Proxy, but looks like it can't help.
Two suggestions:
MySQL Proxy
This is a front end proxy from MySQL which does what you want as far as I know
vtocc
From the vitess project, used in the YouTube mysql environment, also does a similar thing. Query consolidation: The ability to reuse the results of an in-flight query to any subsequent requests that were received while the query was still executing.
You may want to look into HAProxy and how it works.
Here two additional suggestions
SUGGESTION #1 Setup a Cluster
If your data is all InnoDB, you should try Percona XtraDB Cluster and use HAProxy in conjunction with it. You can load balance across all server in the Cluster including the Write Master.
SUGGESTION #2 Setup a Cluster via MySQL Replication to 1 or more DB Servers
Use HAProxy to load balance your reads across the Read Slaves
If you are on a budget and your data is relatively small, setup multiple MySQL Instances on one server