当前位置:网站首页>SQL master-slave replication setup
SQL master-slave replication setup
2022-06-28 07:53:00 【Fairy wants carry】
Catalog
mysql Master-slave introduction
mysql Master-slave introduction

mysql To copy from a computer :
slave From master Read binlog To synchronize data
1 master The host logs the changes to the binary log (binary log). These recording processes are called Binary log events ,binary log events;
2 slave take master Of binary log events Copy to its trunk log (relay log);
3 slave Redo events in relay log , Apply the changes to your own database . MySQL Replication is asynchronous and serialized
Several processing modes :

statement Pattern : You can't use functions , For example, your host uses functions now() Record the time, but when synchronizing to the slave , His time will change ( Obviously inconsistent ), This will cause the master-slave replication data to be sent in case of inconsistency ( I feel a bit like RDB, Direct data synchronization , There will be data inconsistencies );
Row mode row: Low efficiency , Record the changes in each line , If the data volume reaches a level, it will be very slow ( I feel a bit like AOF, Give each line of the slave to execute );
MIXED Pattern : A combined version of the previous two modes ;
Master slave building
Modify the configuration file of the host :
Find the host first mysql Configuration file for my.ini, Then configure Log files Directory and settings of Databases that don't need to be replicated and The name of the database to be copied


Then modify the configuration file of the slave :
Yes my.cnf File modification

1. Create a user in the host , Have all permissions in the native database
# On host local , Give the remote permission
GRANT REPLICATION SLAVE ON *.* TO 'slave190401'@'%' IDENTIFIED BY '123';

View the host database status
show master status 
2. restart mysql host

3. And then in linux Next restart our mysql Slave
systemctl restart mysqld
4. Then let's look at mysql Of status, Find out running active that will do
systemctl status mysqld
5. And then in window Close all firewalls
And close linux Under the firewall stop
systemctl status firewalld
mysql Master slave copy and redis Those are a bit similar
Accessing the host from the host Binary log All need to be verified , See if you can visit , And ours redis The cluster accesses the host from the host ( That is, to get the host RDB、AOF file ), You also need to verify whether the data is loaded for the first time , And this verification is to see id Is it the same
Binlog_Do_DB and Binlog_Ignore_DB It refers to the database to be copied and the database not to be copied
At this time, the host computer should not be responsible for this Bin_Do_DB Database operation , This is the master-slave database , If it changes ,Position Will send changes

6. At this point, we need to deal with linux Under the mysql To operate : Thanks to the host , Follow slave of It's kind of like
CHANGE MASTER TO MASTER_HOST='192.168.184.1',
MASTER_USER='slave190401',
MASTER_PASSWORD='123',
MASTER_LOG_FILE='mysqlbin.000001',MASTER_LOG_POS=107;
7. If there is a problem from the slave to the host , need reset once
stop slavereset masterThen we start master-slave replication
start slave8. Check the slave status ( similar redis Medium info replication)
show slave status\G
Operate on the host database
Operate on the host to create mydb_190401 After the database , It is found that the database to which the slave user is connected also has
There is a delay , millisecond , perfect bro

If there is a mistake in your order to worship brother from the machine , direct stop slave Stop slave , then reset master that will do ——> Go back to the executive brother Before the command
边栏推荐
- 什么是EC鼓风机(ec blower fan)?
- flex布局
- Disposition Flex
- Safety training is the greatest benefit for employees! 2022 induction safety training for new employees
- Section VI UART of zynq
- SOC clock configuration
- 2021 programming language ranking summary
- MMR rearrangement (similarity is calculated by editing distance and repeatability)
- 云原生:云计算技术再次升级 开启全面云开发时代
- Section VII starting principle and configuration of zynq
猜你喜欢

ZYNQ_ IIC read / write m24m01 record board status

什么是EC鼓风机(ec blower fan)?

HJ prime factor

LeetCode之三步问题

Hash slot of rediscluster cluster cluster implementation principle

golang gin框架进行分块传输

Analyze 5 indicators of NFT project

2021 programming language ranking summary

Kubernetes deploys a secret pit where thanos ruler sends repeated alarms

Spark 离线开发框架设计与实现
随机推荐
Design and implementation of spark offline development framework
Generation and verification of JWT token
7-2 Finnish wooden chess structure Sorting
Section Xi. Axi of zynq_ Use of DMA
QT -- communication protocol
Section 8: DMA of zynq
股票炒股注册开户靠谱吗?安全吗?
ACM notes
Study notes 22/1/17
Soft exam -- software designer -- afternoon question data flow diagram DFD
Resizing node of rediscluster cluster cluster mode
Modifying MySQL port number under Linux
Explanation and application of instr() function in Oracle
券商注册开户靠谱吗?安全吗?
22/02/14 study notes
什么是EC鼓风机(ec blower fan)?
2021 programming language ranking summary
HJ string sort
flex布局
【js】-【节流、防抖函数】