MARIADB Multiple source replication data rollup, as shown in the following figure, in some scenarios, there are A and b two node databases, from the data to read AB Two nodes data to a Slave database
Main A and main B:
[Root@master local]# Tar XF mariadb-10.0.10-linux-x86_64.tar.gz
[Root@master local]# ln-sv mariadb-10.0.10-linux-x86_64 MySQL
' MySQL '-> ' mariadb-10.0.10-linux-x86_64 '
[Root@master local]# CD mysql/
[Root@master mysql]# scripts/mysql_install_db--user=mysql--datadir=/mydata/data/
[Root@master mysql]# CP support-files/my-large.cnf/etc/mysql/my.cnf
Modify Server-id, binary Log-bin open,
DataDir =/mydata/data
Basedir =/usr/local/mysql
Innodb_file_per_table = On
Skip_name_resolve = On
Log-bin=/mydata/binlogs/master-1
Binlog_format=mixed
Server-id = 1
Create a replication account on both main A and main B, respectively:
GRANT REPLICATION slave,replication CLIENT on *.* to ' user ' @ ' 192.168.%.% ' identified by ' pass ';
From the server:
Comment out Log-bin
Add Relay-log
#log-bin=mysql-bin
Server-id = 10
Relay-log = Relay-bin
On the server from the following:
From the server need to turn on the relay log, modify the server_id number, from the server still cannot write, can only read
Change MASTER ' M1 ' to master_host= ' 192.168.0.100 ', master_user= ' USER ', master_password= ' pass ';
Change MASTER ' m2 ' to master_host= ' 192.168.0.101 ', master_user= ' USER ', master_password= ' pass ';
As follows:
MARIADB [(None)]> change MASTER ' M1 ' to master_host= ' 192.168.0.100 ', master_user= ' USER ', master_password= ' pass ';
Query OK, 0 rows affected (0.02 sec)
MARIADB [(None)]> change MASTER ' m2 ' to master_host= ' 192.168.0.101 ', master_user= ' USER ', master_password= ' pass ';
Query OK, 0 rows affected (0.03 sec)
MARIADB [(None)]> start all slaves;
When OK, use the command to view! Show All Slaves status\g
Because it is the first time that you use empty data, you may need to manually specify it from the server, as shown below!
After you close the slaves, view them separately on Master1 and 2 and change them again
MARIADB [(None)]> stop all slaves;
Master-1
Mariadb [(none)]> Show Master status;
+-----------------+----------+--------------+------------------+
| file | Position | binlog_do_db | binlog_ignore_db |
+-----------------+----------+--------------+------------------+
| master-1.000003 | 325 | | |
+-----------------+----------+--------------+------------------+
Mariadb [None]]> change MASTER ' M1 ' to Master_host= ' 192.168.0.100 ', master_user= ' USER ', master_password= ' pass ', master_log_file= ' master-1.000003 ', MASTER _log_pos=325;
Master-2
MARIADB [(None)]> Show Master status;
+-----------------+----------+--------------+------------------+
| File | Position | binlog_do_db | binlog_ignore_db |
+-----------------+----------+--------------+------------------+
| master-2.000001 | 518 | | |
+-----------------+----------+--------------+------------------+
1 row in Set (0.00 sec)
MARIADB [(None)]> change MASTER ' m2 ' to master_host= ' 192.168.0.101 ', master_user= ' USER ', master_password= ' pass ', Master_log_file= ' master-2.000001 ', master_log_pos=518;
Open slaves;
MARIADB [(None)]> start all slaves;
View
MARIADB [(None)]> Show All Slaves status\g
1. Row ***************************
Connection_name:m1
Slave_sql_state:slave has read all relay log; Waiting for the slave I/O thread to update it
Slave_io_state:waiting for Master to send event
master_host:192.168.0.100
Master_user:user
master_port:3306
Connect_retry:60
master_log_file:master-1.000003
read_master_log_pos:532
relay_log_file:relay-bin-m1.000003
relay_log_pos:534
relay_master_log_file:master-1.000003
Slave_io_running:yes
Slave_sql_running:yes
replicate_do_db:
replicate_ignore_db:
Replicate_do_table:
Replicate_ignore_table:
Replicate_wild_do_table:
Replicate_wild_ignore_table:
last_errno:0
Last_error:
skip_counter:0
exec_master_log_pos:532
relay_log_space:1321
Until_condition:none
Until_log_file:
until_log_pos:0
Master_ssl_allowed:no
Master_ssl_ca_file:
Master_ssl_ca_path:
Master_ssl_cert:
Master_ssl_cipher:
Master_ssl_key:
seconds_behind_master:0
Master_ssl_verify_server_cert:no
last_io_errno:0
Last_io_error:
last_sql_errno:0
Last_sql_error:
Replicate_ignore_server_ids:
Master_server_id:1
MASTER_SSL_CRL:
Master_ssl_crlpath:
Using_gtid:no
Gtid_io_pos:
retried_transactions:0
max_relay_log_size:1073741824
Executed_log_entries:12
slave_received_heartbeats:0
slave_heartbeat_period:1800.000
gtid_slave_pos:0-1-2141
2. Row ***************************
Connection_name:m2
Slave_sql_state:slave has read all relay log; Waiting for the slave I/O thread to update it
Slave_io_state:waiting for Master to send event
Master_host:192.168.0.101
Master_user:user
master_port:3306
Connect_retry:60
master_log_file:master-2.000001
read_master_log_pos:518
relay_log_file:relay-bin-m2.000003
relay_log_pos:534
relay_master_log_file:master-2.000001
Slave_io_running:yes
Slave_sql_running:yes
replicate_do_db:
replicate_ignore_db:
Replicate_do_table:
Replicate_ignore_table:
Replicate_wild_do_table:
Replicate_wild_ignore_table:
last_errno:0
Last_error:
skip_counter:0
exec_master_log_pos:518
relay_log_space:1114
Until_condition:none
Until_log_file:
until_log_pos:0
Master_ssl_allowed:no
Master_ssl_ca_file:
Master_ssl_ca_path:
Master_ssl_cert:
Master_ssl_cipher:
Master_ssl_key:
seconds_behind_master:0
Master_ssl_verify_server_cert:no
last_io_errno:0
Last_io_error:
last_sql_errno:0
Last_sql_error:
Replicate_ignore_server_ids:
Master_server_id:3
MASTER_SSL_CRL:
Master_ssl_crlpath:
Using_gtid:no
Gtid_io_pos:
retried_transactions:0
max_relay_log_size:1073741824
Executed_log_entries:10
slave_received_heartbeats:0
slave_heartbeat_period:1800.000
gtid_slave_pos:0-1-2141
2 rows in Set (0.00 sec)
MARIADB [(None)]>
If the data is inconsistent, you can reset slave refresh try
MARIADB [(none)]> reset slave ' M1 ';
Query OK, 0 rows Affected (0.00 sec)
Query OK, 0 rows Affected (0.00 sec)
MARIADB [(None)]> START all slaves;
Query OK, 0 rows affected, 2 warnings (0.11 sec)
MARIADB [(None)]>
Multi-source replication, each source should use different data, multi-source replication does not currently support synchronous replication;