## Tutorial for Production (mysql_replicator_multi) It is very useful to replicate a millions of records and/or multiple tables with multiple threads. This architecture is storing hash table in mysql management table instead of ruby internal memory. **Note:** On syncing 300 million rows table, it will consume around 20MB of memory with ruby 1.9.3 environment. ### prepare It has done with follwing two steps. * create database and tables. * add replicator configuration. ##### create database and tables. ``` $ mysql -umysqluser -p -- For the first time, load schema. mysql> source /path/to/setup_mysql_replicator_multi.sql ``` see [setup_mysql_replicator_multi.sql](https://github.com/y-ken/fluent-plugin-mysql-replicator/blob/master/setup_mysql_replicator_multi.sql) ##### add replicator configuration. Let's download sql first. ``` $ wget https://raw2.github.com/y-ken/fluent-plugin-mysql-replicator/master/setup_mysql_replicator_multi.sql ``` ```sql -- Build mysql> source /path/to/setup_mysql_replicator_multi.sql -- Set working database mysql> use replicator_manager; -- Add replicate source connection and query settings like below. mysql> INSERT INTO `settings` (`id`, `is_active`, `name`, `host`, `port`, `username`, `password`, `database`, `query`, `prepared_query`, `interval`, `primary_key`, `enable_delete`) VALUES (NULL, 1, 'mydb.mytable', '192.168.100.221', 3306, 'mysqluser', 'mysqlpassword', 'mydb', 'SELECT id, text from mytable;', '', 5, 'id', 1); ``` it is a sample which you have inserted row.
id | is_active | name | host | port | username | password | database | query | prepared_query | interval | primary_key | enable_delete | enable_loose_insert | enable_loose_delete |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 1 | mydb.mytable | 192.168.100.221 | 3306 | mysqluser | mysqlpassword | mydb | SELECT id, text from mytable; | 5 | id | 1 | 0 | 0 |