0

this is my first post here, and I have searched for a good answer to this question with no luck so far. I am in the process of upgrading our web server (LAMP stack on CentOS 6) to new hardware and more recent software. I'll be migrating our sites to this server when I finish setting it up. I would like to be able to also reinstall the older hardware and essentially make a failover setup of the newer hardware.

My question may or may not be a simple one to answer. I am not an expert by any stretch when it comes to this side of the software stack. Would it be better to install the complete LAMP stack on each server, rsync the sites, and set up database mirroring in MariaDB, or would it be better to only mirror the sites with rsync, and then point the two web servers to a separate database server? I realize the latter would provide a single point of failure, but having never set up database mirroring I want to be sure I'm choosing the right option.

Or are both these options off base, and should I set up a 2 node server cluster?

TheMalman
  • 3
  • 3

2 Answers2

0

Read about "Replication". That takes care of continually syncing one machine (the Master) to another (the Slave). A variation on Master-Slave is "Dual Master". But if you set that up, be sure to write to only one Master. "Failover" is still somewhat manual, but it is better than loading an old backup. Dual Master has some of the failover work already done.

Alternatively, since you are starting with MariaDB, consider using a Galera Cluster since it is bundled with MariaDB. To be HA, you need 3 servers, not just two. So this may be too much of a stretch for you.

The rest of the LAMP stack won't know or care about what you do in the way of Replication. Except that the 'P' needs to know where the Master is -- either locally, or on the other machine. And changing that is part of "failover".

Rick James
  • 2,058
  • 5
  • 11
  • Master-slave with a manual failover is more or less the direction I've gone in after finding some more things to read about all the options in my question. I'm not sure what you mean in your last paragraph though regarding PHP needing to know where the master is. Is that assuming I implement what you suggest in the second paragraph regarding a Galera Cluster? – TheMalman Apr 29 '19 at 18:32
  • @TheMalman - PHP needs to connect to the Master at least for writes. After a failover, a different machine is the Master, so either the connection parameters need to change, or you need a 'proxy' to redirect to the current Master. (etc) – Rick James Apr 29 '19 at 18:54
  • Thanks for the clarification. So just a followup question or two. If I only use the master server for all web service, meaning all users will only ever access that master LAMP server, would I still need to point PHP on the backup server to the master db? I was intending to rsync the web files and apache logs to the backup server to keep everything essentially the same on both servers. – TheMalman Apr 30 '19 at 18:03
  • @TheMalman - If the Master fails and you failover to the backup Master, what will PHP do until you fix the dead Master and failback to it? – Rick James Apr 30 '19 at 19:12
  • Well, it was my intention that it would use its local copy of the database that was being mirrored from the failed master server. – TheMalman Apr 30 '19 at 19:28
  • That still means that it must "connect" to the database differently. – Rick James Apr 30 '19 at 19:45
0

You can setup Active-Standby mariadb cluster it usage Corosync/Pacemaker. There is good document with steps to setup from scratch on MariaDB official site. There are multiple ways to setup apache load balancer like UltraMonkey and many more. Hope it will help.

asktyagi
  • 2,401
  • 1
  • 5
  • 19