大网数据广告活动
服务器运维问答

How to handle failover for wordpress woocommerce store?

· 52CE 我爱测

I am working on a project with multiple WordPress + Woocommerce stores. We have 3 dedicated servers. As the traffic grows. Sometimes, the server is down. I am looking for a failover solution that works with those wordpress+woocom…

问题原文

原帖链接 · Philip · CC BY-SA 4.0

I am working on a project with multiple WordPress + Woocommerce stores. We have 3 dedicated servers. As the traffic grows. Sometimes, the server is down. I am looking for a failover solution that works with those wordpress+woocommerce sites.

First, I found CloudFlare. It will automatically failover to the other “A” record. So I just need to replicate all files and database to other server as backup. When the first server is down, it will point to another server.

But this comes with another problem. When it points to the second server. All the data in the database goes back to when the backup is created. And when the original server is fixed, the domain points back to the original server. Then all data written in second server is gone as it didn't write into the original server.

Then I looked into the master-slave replication of database. Assuming the original server is master and the second server is slave, each time when a customer bought a product or wrote a comment, it writes into the master database. Then the slave database sync the master database. But the problem is that when the original server is down. It switches to the slave database with is read-only. So even the customers could load the website. They could not make purchase or comment.

I have no idea what to do next. Please help. Thank you. We would like to archive the followings:

  • switch servers when one is down
  • sync database anytime. No data loss during the switching process

已采纳解答

原帖链接 · Tomas · CC BY-SA 4.0

Since you have 3 dedicated servers, you can use a Galera 3-node cluster in order to have active-active database clusters, that way you don't have to point to a specific node, but rather they all work as one.

https://mariadb.com/kb/en/getting-started-with-mariadb-galera-cluster/

You will also need a load balancer, but you can use haproxy on each of the servers with a virtual-IP in order to load balance and make the setup in HA mode.

Then, you will also need 3 instances of WP, so you could use something like a NFS disk to export the same mount point to all servers, or, sync via a cron to the servers every say, 1 minute.

Of course, this is much easier with a cloud provider, but it's definitely doable with your 3-dedicated servers setup.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2021-05-16)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。