简体   繁体   English

Galera Mariadb 多主复制

[英]Galera Mariadb Multi-Master Replication

I am trying to setup a cluster of 3 servers in 3 different locations;我正在尝试在 3 个不同的位置设置一个由 3 个服务器组成的集群; Dallas-US, London-UK, Mumbai-India.达拉斯-美国、伦敦-英国、孟买-印度。 On each location I have setup a webserver and db server.在每个位置我都设置了一个网络服务器和数据库服务器。 On db server I have configured Galera Mariadb Multi-Master cluster to replicate db among all three servers.在数据库服务器上,我配置了 Galera Mariadb 多主集群以在所有三台服务器之间复制数据库。 My each webservers are connected with local IP to their regional db server.我的每个网络服务器都与本地 IP 连接到他们的区域数据库服务器。 I am expecting that my Dallas webserver will fetch db records from Dallas db server;我期待我的达拉斯网络服务器将从达拉斯数据库服务器获取数据库记录; London webserver from London db server and Mumbai webserver from Mumbai db server.来自伦敦数据库服务器的伦敦网络服务器和来自孟买数据库服务器的孟买网络服务器。

Everything is working well but I have found that mysql query takes much time above 100s while fetching record.一切运行良好,但我发现 mysql 查询在获取记录时需要超过 100 秒的时间。 I have tried Mariadb with single instance and its fetching data within 5s.我已经尝试过 Mariadb 与单个实例及其在 5 秒内获取数据。

What am I doing wrong?我究竟做错了什么?

It is possible to configure Galera to be single-Master.可以将 Galera 配置为单主控。 It does not sound like you did that, but suggest double checking.听起来你没有这样做,但建议仔细检查。

Given that all nodes are writable, here's a simplified view of what happens on each transaction.鉴于所有节点都是可写的,这里是每个事务发生的简化视图。

  1. Do all the work to store/update the data on the Master you are connected to.完成所有工作以存储/更新您所连接的 Master 上的数据。 (Presumably, it is the local machine.) (大概是本地机器。)
  2. At COMMIT time, make a single round-trip to each other nodes (probably ~200ms) to give them a chance to say "wait. that would cause a conflict".在提交时,对其他节点进行一次往返(可能约为 200 毫秒),让它们有机会说“等待。这会导致冲突”。
  3. Usually step 2 will come back with "it's OK".通常第 2 步会返回“没关系”。 At this point, the COMMIT returns success to the client.此时, COMMIT向客户端返回成功。

(Note: If you are not using BEGIN...COMMIT , but instead auto_commit=ON , then there is an implicit COMMIT at the end of each DML statement.) (注意:如果您没有使用BEGIN...COMMIT ,而是使用auto_commit=ON ,那么每个 DML 语句的末尾都会有一个隐式COMMIT 。)

For a local read, the default action should return "immediately".对于本地读取,默认操作应“立即”返回。

But, maybe you are concerned about the "critical read" problem.但是,也许您担心“批判性阅读”问题。 (cf wsrep_sync_wait ) In this case, you want to make sure that a write has propagated to your server. (cf wsrep_sync_wait )在这种情况下,您要确保写入已传播到您的服务器。 This is likely to lead to a 200ms delay on the read because it waits for the "gcache" is caught up.这可能会导致读取延迟 200 毫秒,因为它等待“gcache”被赶上。

If you can assume that only read from the same server that they write to, consider setting wsrep_sync_wait=0 .如果您可以假设仅从他们写入的同一服务器读取,请考虑设置wsrep_sync_wait=0 If anyone does a cross-datacenter write, then read, he could hit the "critical read" problem.如果有人进行跨数据中心写入,然后读取,他可能会遇到“关键读取”问题。 (This is where he writes something, but may not see it on the next read.) (这是他写东西的地方,但下次阅读时可能看不到。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM