Master-Master Replication [Percona] - mysql

Please forgive my ignorance but I do not have a ton of experience with MySQL. I am a web developer but overall I have pretty much just installed MySQL or spun up an RDS instance, connected to it and everything just works. However I am currently being tasked with creating a complete backup of our primary server (essentially high availability with a load balancer etc). So I thought now might be a good time to change how I haver our MySQL setup to take advantage of having 2 servers. Currently our MySQL lives on our primary servers and that will probably stay that way for now, however my goal with this new setup is to have 2 identical servers, both running the application and both having the exact same MySQL data structure / data. I want to be able to essentially open up the web application on one server, make a change, see it on the other or vica versa.
From my research it looks like what I want is called "Master-Master Replication" however it seems as if this is an older / more outdated approach? Every article I read is from ~2010-2012 and most people say it is depreciated and I should use Percona XtraDB Cluster, MySQL Group Replication, or Galera Cluster etc. I basically have no idea what any of that means and I am looking for the easiest way to get Master-Master type setup working. On top of that even if I wanted to use regular Master-Master replication it seems as if this is something specific to MySQL and not Percona which is what I actually use.
I know plenty about dev ops and can get everything but the MySQL up and running in no time but I would love some insight on the best way to do this. Currently servers are running Centos 7, Percona 5.7, Apache 2.4.

The easiest way to start is to setup a percona xtradb cluster with proxysql.
Percona xtradb cluster handles all the problems that are present in basic MySQL Master-Master Replication.
Both Galera and Percona Xtradb CLuster are same, as they use the same galera plugin, Only that Percona has customized it and added some extra features like in built proxysql( kind of load balancer for database).

Let's clear up one thing first. Percona is MySQL. If a feature is available on Oracle MySQL (the community version is what I am referring to here), then it is also available on Percona. Think of the two like a cake: MySQL is the base "cake" and Percona is the frosting/sprinkles/etc that go on top.
That being said you can absolutely do Master/Master using Percona MySQL. The standard/best practice is to configure this in active/hot-standby. Meaning, do not write to both nodes at the same time. Your application, or your middleware/proxy, must isolate writes to only one node. This will save you insane headaches when/if replication breaks.
ProxySQL is not a Percona product, but we do support it 100%. You can place ProxySQL in front of your M/M and setup the correct query rules to only route to one MySQL.
You are correct that the most modern solution here, and in my opinion, an easier solution, is to set up a 3-node Percona XtraDB Cluster (PXC). Again, Galera MySQL is the "cake" and PXC is all the extras on top. Group Replication is pie (just to continue the analogy.)
We consider a 3-node PXC fronted with ProxySQL to be one of the best HA solutions out there for MySQL. It is still best practice to only write to one node, and utilize the other 2 for read-only queries. If the primary node goes down, each of the other two have an up-to-the-transaction copy of the data. Again, ProxySQL helps route the traffic if primary goes down.
Backups can be taken from any PXC node using Percona XtraBackup in a non-blocking/hot fashion.

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.

MariaDB and MySQL in mixed environments - Replication issue with master/slave design

I am designing a data replication solution across timezones and have run into the issue where I can only run and old version of MySQL (5.6) in one location, whereas the other two have MariaDB 10.2.
Now, I have read the information about Replication Compatibility over at MariaDB. Clearly I can't use MariaDB as a master and MySQL as a slave.
Intermediate solution based on Bash scripts
Yet, I want to use my EU server as a master and that is running MariaDB. So I'm now contemplating a way around the limitation. So far I have come up with an intermediate data storage solution in the overseas server, where data is shuffled periodically using my own Bash data migration scripts over a low bandwidth link.
MariaDB is required in the primary location
I have to use MariaDB in my primary location because I'm using the ColumnStore database there. That is unconditional as part of the application design.
Does this situation ring a bell?
Do you have experience with similar situations and would you mind sharing some inspiration as for how you did it?
My best solution so far is with Bash scripts that are cronned, where MySQL data is dumped (mysqldump) and transferred over a low bandwidth link, then merged with the master (ColumnStore storage engine). I'm looking at a T+1 data lag between my primary location and the secondary location that is running MySQL.
Any high level design thoughts or shared experience is highly appreciated.
Best regards

General thoughts on my MariaDB Master-Master setup (also upgrading procedure)

I've just setup MariaDB on Ubuntu VMs with Master-Master replication using a combination of these three guides:
http://www.chriscouture.com/setting-up-replication-on-mariadb/
https://www.server-world.info/en/note?os=Ubuntu_16.04&p=mariadb&f=3
https://www.digitalocean.com/community/tutorials/how-to-set-up-mysql-master-master-replication
In short, both are masters and both are slaves to the other one. This will be used by separate web hosting servers. One will be "primary master" which all web servers connect to, and in case of a failure on that server they will be manually changed to the "secondary master".
The reason I went for this instead of Master-Slave is
The 3rd party backup job is simpler. Both backups and restores are done on the "secondary" master, instead of backup from the secondary and restoring to the primary.
If the primary fails and I have to switch to the secondary for a while, all changes made during that time should be written to the primary when it comes online again (?).
It's not live yet but everything works fine so far when I'm testing it. However I'm no DBA. I've been reading about how it's not "worth it" and if you don't absolutely need the Master-Master you should go with Master-Slave.
Now I'm afraid I will run into problems like inconsistencies and other headaches.
A maximum of about 100 databases for mostly Wordpress installations will be hosted.
What are your thoughts on the matter? M-M or M-S?
If M-S, how do I "sync back" data changed if the Master goes down and the Slave need to be the active server for a period of time?
I'm also wondering if there's a standard, generally accepted, step-by-step way to upgrade these. I'm thinking when a OS or MariaDB version upgrade is needed.
My general thoughts are something like take down one server, upgrade it, start it. Then take down the other, upgrade it, start it.
But I'm guessing there's more to it than that.
I only found some documentation on M-S upgrading with Mysql.

Will Wordpress work with MySQL Master Master replication?

I am looking at creating a high availability Wordpress installation across two servers with a load balancer to distribute the traffic between these servers, I intend to setup a LAMP stack on these two web servers and configure MySQL master master replication to ensure both servers have the same content similar to the setup at https://www.linode.com/docs/websites/cms/high-availability-wordpress
For anyone created a similar setup before, is there anything to watch out for? Will this work without there being differences in the database assuming both nodes are online? If one node goes down will this synchronise with the other master node successfully?
This is a pretty old post, but I've set up exactly this recently.
I do not recommend setting up WordPress with master-master replication. The nodes went out of sync multiple times and resulted in split-brain. We've reverted back to master-slave replication because of the instability of the setup.
I recently tried this and regret it. I realize your post is now almost 2 years old, but thought I should put in my 2 cents for anyone considering this approach. I recommend you go with MariaDB with MaxScale to separate the reads and writes, and go with master-slave configuration. I'm running into all sorts of deadlocks, and issues with this configuration. Currently using MariaDB with Galera, with HAProxy up front.

MySQL Multi-master replication

We have some (10-) MySQL server nodes and we want them to be replicated in a way that if one goes down the rest never get affected.
I know MySQL provides Master/Slave (not good for us) and Multi-Master replication.
Does MySQL Multi-Master replication work like a mesh? I mean all nodes can get updated from all other nodes?
Is it true that even in Multi-Master replication (MySQL) each node can only get the data from one master???
So if the native MySQL replication features can not fulfill our requirement, do you know any tool that can do this? Our preference is the built-in MySql replication.
The answer to your problem is simple yet very technical aswell. Traditional MYSQL tools cannot help so you need help of Galera cache from codership. Some features are synchronous replication which MYSQL do not offer, and it works as a cluster if you have a galera MYSQL cluster setup, one goes down rest keeps on going.
I personally use Percona xtradb cluster for this, percona xtradb cluster is patched version of MYSQL and galera embeded together. All servers can take reads and writes.
I have written an article on installing this but cannot post here as stack overflow may consider as link building.
DO some research on Galera, as you use normal MYSQL in a cluster environemnt, FULL HA and HS.
If you need some more info feel free to discuss it with me.
Thanks...
I've been researching this as well. MySQL seems to offer multi-master replication. It's explained here: http://www.onlamp.com/pub/a/onlamp/2006/04/20/advanced-mysql-replication.html
and a more complex example with masters and slaves here: http://capttofu.livejournal.com/1752.html.
There are 3rd party tools as well and the one that seems to come up often is Tungsten: http://code.google.com/p/tungsten-replicator/
And here's an excellent article on multi-master replication with MySQL: http://scale-out-blog.blogspot.com/2012/04/if-you-must-deploy-multi-master.html