Link to home
Start Free TrialLog in
Avatar of bibi92
bibi92Flag for France

asked on

Mysql how to replicate only one table

Hello,

I search a procedure to replicate only one table.

Thanks

Regards

bibi
Avatar of ExtraWebdesign
ExtraWebdesign

from mysql.com:

--replicate-do-table=db_name.tbl_name

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
Avatar of arnold
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-table=db4.%
--replicate-do-table=db1.table1

This was used the 'catch' extra queries that were using the wrong default database.

Just something else to consider.
Avatar of bibi92

ASKER

Thanks, but where I have to configure this in master or slave ?

--replicate-do-db=db4
--replicate-wild-ignore-table=db4.%
--replicate-do-table=db1.table1
Thanks
bibi
ASKER CERTIFIED SOLUTION
Avatar of marklogan
marklogan
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you want you can put them in the startup command instead.

/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --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

Avatar of bibi92

ASKER

Sorry, it's an error, I want to close with 500 for marklogan.
Avatar of bibi92

ASKER

error : 500 points for marklogan
Allocate points correctly.

Thank you bibi92.
Avatar of bibi92

ASKER

Thanks a lot bibi