HAProxy for MySQL Master Slave Repliation - mysql

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.

Related

Detection of outdated replicas at mysql router

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:

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 .

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!

replication normal mysql to cluster

Surprisingly I can't find anything on the internet which speaks to this. We currently have a master slave slave mysql set up. We are considering making a move to mysql cluster, for scalability reasons. It would be really nice if we could make the cluster a slave of the current master and run a dev environment off the cluster for now. Even better would be if we could do a master master relationship between the current master and the cluster.
Our concern is that our data has to be kept very current, so not being able to do this replication would mean downtime. If this replication is not possible, what is the smoothest possible way to make the transition. We're currently running mariaDB.

setting up replication in mysql pros and cons

Basically I want to setup a replication server for mysql datbase. I am completely new to this concept and appreciate any help pointing me in the right direction.
If at all the slave goes down, will it effect the master in anyway?
Thanks.
No, it will not affect the master if the slave goes down. The Slaves connect to the master and request the changes.
If you intend on having 2 servers replicated, then you can use Master-Master replication. This means that either one of the database servers can go down without loss of data or access. This is extremely resilient to failure however you can get duplicate key errors on fast successive inserts, like using MySQL to handle sessions. This can be solved programatically through.
The downside of the Master-Slave set up is that if the master fails you have to manually assign another Master, fix the failed master and then bring back into the group. Otherwise failure of any or all Slaves will not affect the Master.