Can I synchronize tables from different libraries on different machines to the same library in the same machine? Tables are different. And for slave This machine, these tables are for reading only.
Synchronizing tables of different libraries is easy, with
Replicate-do-table=db_name.tbl_name
Multiple tables of different libraries on different machines are synchronized to the same library in the same machine, plus the following sentence.
Replicate-rewrite-db=from_name->to_name
Configuring MY.CNF on the Slave
Cat MY.CNF
[Mysqld_multi]
Mysqld =/usr/local/mysql/bin/mysqld_safe
Mysqladmin =/usr/local/mysql/bin/mysqladmin
[Mysqld1]
Port = 3306
Socket =/tmp/mysql.sock1
Skip-locking
Pid-file=/usr/local/mysql/data/test-db1a.pid
DataDir =/usr/local/mysql/data
Log=/usr/local/mysql/data/test-db1.log
user = MySQL
Log-slow-queries=/usr/local/mysql/data/slowquery1.log
Long_query_time = 2
Key_buffer = 256M
Max_allowed_packet = 1M
Table_cache = 512
Sort_buffer_size = 2M
Read_buffer_size = 2M
Myisam_sort_buffer_size = 64M
Thread_cache = 32
Query_cache_size = 32M
Thread_concurrency = 2
max_connections=500
Server-id = 2
Master-host = 192.168.0.1
Master-user = ' Replcate '
Master-password = ' 1234567890 '
Master-port = 3306
Report-host = test-db3
Master-connect-retry = 30
Log-bin
Log-slave-updates
Replicate-rewrite-db=from_name->to_name
Replicate-do-table=db_name.tbl_name
[Mysqld2]
Port = 3307
Socket =/tmp/mysql.sock2
Pid-file =/usr/local/mysql/data/test-db2b.pid
DataDir =/usr/local/mysql/data
Log=/usr/local/mysql/data/test-db2.log
user = MySQL
Log-slow-queries=/usr/local/mysql/data/slowquery2.log
Long_query_time = 10
Key_buffer = 128M
Max_allowed_packet = 1M
Table_cache = 512
Sort_buffer_size = 1M
Read_buffer_size = 1M
Myisam_sort_buffer_size = 32M
Thread_cache = 32
Query_cache_size = 16M
Thread_concurrency = 2
max_connections=300
Server-id = 2
Master-host = 192.168.0.2
Master-user = ' Repl '
Master-password = ' 1234567890 '
Master-port = 3307
Report-host = test-db3
Master-connect-retry = 30
Log-bin
Log-slave-updates
Replicate-rewrite-db=from_name->to_name
Replicate-do-table=db_name.tbl_name
Well, look at the above configuration, understand the two mysqld instances using the same library table file, will there be problems?
Of course, the use of improper words will be problematic, first to match two instances read and write objects are not cross. (The only synchronized table), followed by the selection of the appropriate storage engine, myism than InnoDB theoretically more suitable for this application. Using the process again for the two mysqld instances on slave, use only one of the native other library tables (non-synchronous) write operations.
OK, this solution has passed the test.
Source: http://blog.chinaunix.net/uid-220350-id-149202.html
Multi-Master A bold attempt to synchronize tables from MySQL replication.