MARIADB Master-slave replication:
Replication: Each node has the same data set
From node:
I/O Thread: Requests binary log events from Master and remains in the trunk log
SQL Thread: Reads log events from the trunk log and completes the replay locally
Master node:
Dump thread: Launches a dump for each slave I/O thread that is used to send binary log events
Characteristics:
1. Asynchronous replication
2. master-Slave data inconsistency is more common
3. A master more from
4. From the server can also have from the service
Configuration process:
Master node:
1. Start the binary log
2. Set a globally unique ID number for the current node
3. Create a user account with copy permissions
Replication Slave,replication Client
From node:
1. Start the relay log
2. Bit the current node set a globally unique ID number
3. Connect to the primary server with a user account with replication privileges and start the replication thread
Master node: Vi/etc/my.cnf added in [mysqld]: Log-bin=mysql_bin_log #启动二进制日志 server-id=1 #主节点和从节点一定要不通 innodb_file_per_table=on skip_name_resolve=on Restart Mariadb:systemctl restart Mariad b Create a replication user and authorize: MariaDB [(None)]> grant replication slave,replication slave on * * to ' repluser ' @ ' 172.16.%.% ' Identified by ' 123456 ' MariaDB [(none)]> show master logs; +----------------------+-----------+ | Log_name | File_size | +----------------------+-----------+ | mysql_bin_log.000001 | 30379 | | mysql_bin_log.000002 | 1038814 | | mysql_bin_log.000003 | 264 | | mysql_bin_log.000004 | 264 | | mysql_bin_log.000005 | 245 | #记住这个二进制文件名和对应的序号 +----------------------+-----------+ 5 rows in Set (0.00 sec) from node: vi/e Tc/my.cnf added in [mysqld]: Relay-log=relay-log Server-id=2 innodb_file_per_table=on skip_name_resolve=on Restart mariadb:systemctl restart Mar IADB Connection master server: MariaDB [(none)]> change master to master_host= ' 172.16.6.12 ', master_user= ' Repluser ', master _password= ' 123456 ', master_log_file= ' mysql_bin_log.000005 ', master_log_pos=245; Start copying: MariaDB [(none)]> start slave; View replication Status: MariaDB [(none)]> show Slave status\g;
Mariadb master-slave replication