bibi92
asked on
Mysql how to replicate only one table
Hello,
I search a procedure to replicate only one table.
Thanks
Regards
bibi
I search a procedure to replicate only one table.
Thanks
Regards
bibi
The same way as above you can configure the master server to only bin-log transactions for a specific table.
Be careful changing the master to only log transactions for a specific table. It all depends on your setup, but I recently had to setup replication similar to what you are after, several complete databases and a few tables in some other databases.
It turned out a few scripts were setup to use a different database to which the tables were based in.
Similar to examples found in the MySQL manual.
USE db4;
UPDATE db1.table1 SET col1 = 10, db2.table2 SET col2 = 20;
http://dev.mysql.com/doc/refman/5.1/en/replication-options-binary-log.html
I had to setup replication like:
--replicate-do-db=db4
--replicate-wild-ignore-ta ble=db4.%
--replicate-do-table=db1.t able1
This was used the 'catch' extra queries that were using the wrong default database.
Just something else to consider.
It turned out a few scripts were setup to use a different database to which the tables were based in.
Similar to examples found in the MySQL manual.
USE db4;
UPDATE db1.table1 SET col1 = 10, db2.table2 SET col2 = 20;
http://dev.mysql.com/doc/refman/5.1/en/replication-options-binary-log.html
I had to setup replication like:
--replicate-do-db=db4
--replicate-wild-ignore-ta
--replicate-do-table=db1.t
This was used the 'catch' extra queries that were using the wrong default database.
Just something else to consider.
ASKER
Thanks, but where I have to configure this in master or slave ?
--replicate-do-db=db4
--replicate-wild-ignore-ta ble=db4.%
--replicate-do-table=db1.t able1
Thanks
bibi
--replicate-do-db=db4
--replicate-wild-ignore-ta
--replicate-do-table=db1.t
Thanks
bibi
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you want you can put them in the startup command instead.
/usr/local/mysql/bin/mysql d_safe --defaults-file=/etc/my.cn f --replicate-do-db=db4 ... --user=mysql &
Without -- in the my.cnf
With -- in the startup command.
You will also need to create the user on the live server with replication permissions.
http://dev.mysql.com/doc/refman/5.0/en/replication-howto-repuser.html
/usr/local/mysql/bin/mysql
Without -- in the my.cnf
With -- in the startup command.
You will also need to create the user on the live server with replication permissions.
http://dev.mysql.com/doc/refman/5.0/en/replication-howto-repuser.html
ASKER
Sorry, it's an error, I want to close with 500 for marklogan.
ASKER
error : 500 points for marklogan
Allocate points correctly.
Thank you bibi92.
Thank you bibi92.
ASKER
Thanks a lot bibi
--replicate-do-table=db_na
Tells the slave thread to restrict replication to the specified table. To specify more than one table, use this option multiple times, once for each table. This works for both cross-database updates and default database updates, in contrast to --replicate-do-db. See Section 16.2.3, “How Servers Evaluate Replication Filtering Rules”.
This option affects only statements that apply to tables. It does not affect statements that apply only to other database objects, such as stored routines. To filter statements operating on stored routines, use one or more of the --replicate-*-db options.
http://dev.mysql.com/doc/refman/5.1/en/replication-options-slave.html#option_mysqld_replicate-do-table