Mariadb10 Multi-source replication (Multi-sourcereplication) business use scenario analysis, and use method MariaDB
Mariadb 10 Multi-source replication business application scenario analysis and usage
An official mysql slave can only correspond to one master, and mariadb 10 starts to support multi-source replication. a slave can have multiple masters to copy different databases from their respective masters.
This feature can be used in OLAP environments. traditional e-commerce databases are split and split, database and table sharding, while OLAP or big data platform environments usually require aggregation of various data, composite query of multiple DB data on multiple platforms, and the data is scattered in each Database. of course, the application can achieve aggregation, but there is no simpler method, for example, table fields are directly associated with databases on each server. Mysql does not have the DBLINk function of oracle. Although mysql has the federated Engine, it is not very reliable and troublesome, and the performance is unpredictable.
At this time, the advantages of mariadb's multi-source replication function are shown. Directly copy the databases of multiple servers to the same slave. all databases are available.
Other scenarios:
-
Two independent systems transmit interface data through interfaces, such as restful APIs or soap. there are often scenarios where communication data on both sides is inconsistent. how can we check the data. In addition to querying interface logs, you can use multi-source replication to directly write the communication data that SQL associates with the two databases. it is obvious whether the sender transmits the data or the receiver receives the data.
-
DBAs can query data on the same db server, instead of querying data separately on each server.
-
The backup is convenient. this multi-source replication slave is used for backup, so you do not need to copy data to each server.
-
Big data pumping is concentrated on a single DB platform, so you do not need to distribute the pumping data to each DB server. of course, if you have more pumping data, I/O will not be able to handle it. go to the ssd or pcie card.
Next let's talk about the use of methods, it is recommended to see mariadb 10 multi-source copy of the official documentation, https://mariadb.com/kb/en/mariadb/mariadb-documentation/replication-cluster-multi-master/replication/multi-source-replication/
Change the traditional replication mode to multi-source replication:
- Stop slave, show slave status to view the stop position
- Reset slave all;
- Change master 'Conn _ Mall' to master_host = 'master IP ',
MASTER_PORT = 3306, master_user = '', master_password = '',
Master_log_file = 'MySQL-bin.000036 ', master_log_pos = 189492612;
- Start slave 'Conn _ Mall ';
- Show all slaves status/G or show slave 'Conn _ Mall' status/G
Add a new replication Source:
- Export mysqldump from the source end -- master-data = 2
- Slave import
-
Change master 'Conn _ erp 'to master_host = 'master IP ',
MASTER_PORT = 3306, master_user = '', master_password = '',
Master_log_file = 'mysql-bin.000470', master_log_pos = 215418341;
-
Start slave 'Conn _ erp ';
Traditional replication mode-command changes for multi-source replication
- Reset slave-> reset slave 'Conn _ erp ', multiple connection source names
- Start slave-> start slave 'connection _ name' or start all slaves
- Show slave status-> show slave 'Conn _ Mall' status, or show all slaves status to view all slave connection statuses
- SQL _slave_skip_couter-> stop slave 'connection _ name', specify the connection source name set @ default_master_connection = 'connection _ name', and then set global SQL _slave_skip_counter = 1; last start slave 'connection _ name'
Replicate-... variables in multi-source replication environments
You can add a conn connection string prefix before my. cnf replicate_ignore_db. for example, if main_connection.replicate_ignore_db = ignore_database is not prefixed, all databases with the same name are ignored, and other variables are also added.