mariadb 10 多源复制(Multi-source replication) 业务使用场景分_MySQL
MariaDB
mariadb 10 多源复制(Multi-source replication) 业务使用场景分析,及使用方法
官方mysql一个slave只能对应一个master,mariadb 10开始支持多源复制,一个slave可以有多个master,分别从各自的master复制不同的DB。
这个特性可以用在OLAP环境中,传统电商DB都是拆了再拆,分库分表,sharding,而OLAP环境或者大数据平台环境,通常需要各种数据的聚合,多个平台多个DB数据的复合查询,而这些数据分散在各个库中,怎么办了,当然通过应用程序可以实现聚合,但又没有更简单的方法,比如直接对各个server上的库,进行表字段的关联了。Mysql没有oracle的DBLINk的功能,而mysql虽然有federated引擎,但不太靠谱,而且麻烦,性能怎么样不可预知。
这个时候,mariadb的多源复制功能的优势就体现出来了。直接把多个server的db,复制到同一个slave上,所有库都有,想怎么关联就怎么关联。
其他使用场景:
两个独立的系统,通过接口,比如restful api或者soap,进行接口数据传递,经常有两边通讯数据不一致的场景,怎么核查数据了。除了查接口日志,可以使用多源复制,直接写sql关联两个库的通讯数据,到底是发送方传递数据还是接受方接收数据有问题,就很明显了。
DBA可以在同一个DB SERVER上查数,不用到各个server分别查数。
备份方便,集中在这台多源复制slave上进行备份,不用到各个server上去复制。
大数据抽数,集中在一个DB 平台上抽数,不用分散到各个DB server上抽数,当然抽数多了,IO扛不住,上ssd或者pcie 卡吧。
下面讲讲使用方法,建议看mariadb 10 多源复制官方文档吧,https://mariadb.com/kb/en/mariadb/mariadb-documentation/replication-cluster-multi-master/replication/multi-source-replication/
传统复制模式改多源复制:
- stop slave ,show slave status 查看停止位置
- 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 或者show slave 'conn_mall' status /G
新增加一个复制源:
- 源端导出 mysqldump --master-data=2
- slave端导入
-
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';
传统复制模式-》多源复制的命令变化
- reset slave -> reset slave 'conn_erp',多个连接源名字
- start slave -> start slave 'connection_name' 或者start all slaves
- show slave status -> show slave 'conn_mall' status,或者 show all slaves status查看所有的slave连接状态
- sql_slave_skip_couter -> stop slave 'connection_name',先指定连接源名称 set @@default_master_connection='connection_name';然后再set global sql_slave_skip_counter=1;最后start slave 'connection_name'
多源复制环境下的replicate-... variables 变量问题
可以在my.cnf replicate_ignore_db 前添加conn连接串前缀,比如 main_connection.replicate_ignore_db=ignore_database若不加前缀,就是忽略所有同名的数据库,其他变量类推。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

InnoDB's full-text search capabilities are very powerful, which can significantly improve database query efficiency and ability to process large amounts of text data. 1) InnoDB implements full-text search through inverted indexing, supporting basic and advanced search queries. 2) Use MATCH and AGAINST keywords to search, support Boolean mode and phrase search. 3) Optimization methods include using word segmentation technology, periodic rebuilding of indexes and adjusting cache size to improve performance and accuracy.

Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

Article discusses strategies for handling large datasets in MySQL, including partitioning, sharding, indexing, and query optimization.

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]

The article discusses dropping tables in MySQL using the DROP TABLE statement, emphasizing precautions and risks. It highlights that the action is irreversible without backups, detailing recovery methods and potential production environment hazards.

MySQL supports four index types: B-Tree, Hash, Full-text, and Spatial. 1.B-Tree index is suitable for equal value search, range query and sorting. 2. Hash index is suitable for equal value searches, but does not support range query and sorting. 3. Full-text index is used for full-text search and is suitable for processing large amounts of text data. 4. Spatial index is used for geospatial data query and is suitable for GIS applications.

The article discusses creating indexes on JSON columns in various databases like PostgreSQL, MySQL, and MongoDB to enhance query performance. It explains the syntax and benefits of indexing specific JSON paths, and lists supported database systems.
