简体   繁体   English

MySQL 复制(3 个主,1 个从)

[英]MySQL Replication (3 masters, 1 Slave)

I am currently in the process of setting up mySQL replication.我目前正在设置 mySQL 复制。

I need to get data from three places.我需要从三个地方获取数据。

So for example I have所以例如我有

NEED THIS DATA需要这些数据
server1 - database1服务器 1 - 数据库 1
server2 - database2服务器 2 - 数据库 2
server3 - database3服务器 3 - 数据库 3

STORE DATA HERE在此处存储数据
server4 - database4服务器 4 - 数据库 4

I need this for reporting purposes.我需要这个用于报告目的。

I have read you can not connect to more then one master.我读过你不能连接到一个以上的主人。 So with that being said I am going to try a "master-chain" topology because I think I understand what is going on with this one话虽如此,我将尝试一种“主链”拓扑,因为我想我理解这个拓扑是怎么回事

So the data flow will look like this所以数据流看起来像这样

server1 -> server2 -> server3 -> server4服务器1->服务器2- >服务器3- >服务器4

server2 and server3 will have blackhole storage engines for the replicated databases so we don't actually store the information on these servers but the information is still logged to the binary-log so all the statements will trickle down to keep server4 up to date. server2server3将具有用于复制数据库的黑洞存储引擎,因此我们实际上不会将信息存储在这些服务器上,但信息仍会记录到二进制日志中,因此所有语句都会向下传递以使 server4 保持最新。

Am I understanding this correctly?我是否正确理解这一点?

This will work but isn't the nicest implementation and might well cause you problems in the future.这将起作用,但不是最好的实现,将来很可能会给您带来问题。 Before you add a new table on server1 or server2 you'll have to create the BLACKHOLE tables on the downstream servers otherwise you'll end up with the real tables.在 server1 或 server2 上添加新表之前,您必须在下游服务器上创建BLACKHOLE表,否则您将得到真正的表。 I guess you could work around this by writing a script that runs on server2 and server3 each night that looks for any non-blackhole tables and runs an ALTER TABLE to modify them into BLACKHOLE tables.我想你可以通过编写一个每晚在 server2 和 server3 上运行的脚本来解决这个问题,该脚本查找任何非黑洞表并运行ALTER TABLE将它们修改为BLACKHOLE表。

Do you need the reporting data to be bang up to date?您是否需要及时更新报告数据? If not I'd recommend throwing out this whole idea and just pulling dumps of the data into server4 periodically as required.如果不是,我建议放弃整个想法,并根据需要定期将数据转储到 server4 中。

edit: (the next day) After some thought I think that if this was me I would probably look at running three separate MySQL instances on server4 each of them as a direct slave of one of the servers.编辑:(第二天)经过一番思考,我认为如果这是我,我可能会考虑在server4上运行三个单独的 MySQL 实例,每个实例都作为其中一个服务器的直接从属。

Using this approach there's no replication chain , the replication setup is far simpler/normal and each db pair is self contained.使用这种方法没有复制,复制设置更简单/正常,每个数据库对都是自包含的。

It's easy and fairly normal to run multiple MySQL instances, there's even a tool called mysqld_multi that will help you to set it up.运行多个 MySQL 实例既简单又相当正常,甚至还有一个名为mysqld_multi的工具可以帮助您进行设置。

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

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