使用Go和MySQL(故障转移)设置具有容错能力的服务器

huangapple go评论97阅读模式
英文:

Setting up servers with fault tolerance using Go and MySQL (failover)

问题

我正在一个项目中工作,我们使用Go作为Web服务器和MySQL数据库。我们被要求实现容错机制来处理硬件故障。我们得到了两台服务器,上面安装了MySQL和Go服务器。

我们已经成功地在MySQL中设置了复制,但是我们在故障转移部分遇到了困难。我们的想法是使用HAProxy获取一台额外的服务器,以便有一个主服务器,并能够故障转移到备份服务器。我们也考虑使用MySQL故障转移,但是没有看到如何使用它来重定向流量。

这个计划合理吗?或者你有什么其他建议?

英文:

I am working in a project where we are using Go as a web server and MySQL.
We have been told to implement fault tolerance to handle a hardware crash. We were given 2 servers which have MySQL and the Go-server on them.

We have succesfully set up replication in MySQL, but we are struggling with the failover part. Our thought was to get an extra server with HAProxy to have a primary server and then being able to failover to the backup server.
We also considered using MySQL failover, but did not see how we could redirect the traffic using it.

Is this a reasonable plan? Or what would you recommend that we do instead?

答案1

得分: 0

如果您想要两个连接到本地MySQL实例的相同服务器,您需要一种方法来决定哪一个是生产服务器。有许多解决方案可供选择,包括:

  • 设置一个反向代理,就像您提到的那样,但是这样一来,您的代理本身就成为了单点故障。
  • 使用浮动IP,也称为故障转移IP,但这仅在您的主机支持时有效。云提供商通常支持它们,以及一些裸金属服务器提供商。

据我所知,Go语言本身没有特定的解决方案。

英文:

If you want two identical servers connecting to their local MySQL instances, you need a way of deciding which one is the production server. There are a number of solutions for that, including

  • Setting up a reverse proxy, as you mention, but then, your proxy
    itself becomes a SPOF,
  • Using a floating IP, also known as a failover
    IP, but this only works if your host supports it. Cloud providers
    typically support them, as well as some bare metal server providers.

There is nothing specific to Go as far as I know.

huangapple
  • 本文由 发表于 2017年3月22日 17:00:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/42946855.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定