patternsqlMinor
MySQL set one db in server to slave
Viewed 0 times
slaveonemysqlserverset
Problem
I have two MySQL servers (A and B) running on separate machines. I want to replicate database X on A to B. B is still master for other databases. How do I set this up so that B is only slaved for X but master for the others? I currently have A configured to only
replicate-do-dbs=x.Solution
To do this, you don't want to have any filtering on the the
For a full understanding of replication filters, have a read through this documentation and its sublinks. I will highlight two caveats (emphasis mine):
On the master, you can control which databases to log changes for by using the --binlog-do-db and --binlog-ignore-db options to control binary logging.....You should not use these options to control which databases and tables are replicated. Instead, use filtering on the slave to control the events that are executed on the slave.
and
To make it easier to determine what effect an option set will have, it is recommended that you avoid mixing “do” and “ignore” options, or wildcard and nonwildcard options.
With these two pieces of information, I'd recommend setting up
If you need cross-database updates to work, use --replicate-wild-do-table=db_name.% instead.
[src]
Master A server. Instead you will want to use replicate filters on the slave, Server BFor a full understanding of replication filters, have a read through this documentation and its sublinks. I will highlight two caveats (emphasis mine):
On the master, you can control which databases to log changes for by using the --binlog-do-db and --binlog-ignore-db options to control binary logging.....You should not use these options to control which databases and tables are replicated. Instead, use filtering on the slave to control the events that are executed on the slave.
and
To make it easier to determine what effect an option set will have, it is recommended that you avoid mixing “do” and “ignore” options, or wildcard and nonwildcard options.
With these two pieces of information, I'd recommend setting up
server B with --replicate-wild-do-table=db_name.%. This is because:If you need cross-database updates to work, use --replicate-wild-do-table=db_name.% instead.
[src]
Context
StackExchange Database Administrators Q#115152, answer score: 5
Revisions (0)
No revisions yet.