当前位置:网站首页>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 slave
reset master
Then we start master-slave replication
start slave
8. 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
边栏推荐
- Analyze 5 indicators of NFT project
- Unity-UI-shadow组件
- Evaluation of inverse Polish expression < difficulty coefficient >
- Section 8: DMA of zynq
- HJ删除字符串中出现次数最少的字符
- PLC -- Notes
- Disposition Flex
- GPIO configuration of SOC
- Modifying MySQL port number under Linux
- At 19:00 on Tuesday evening, the 8th live broadcast of battle code Pioneer - how to participate in openharmony's open source contribution in multiple directions
猜你喜欢
asp. Net datalist to display product information and pictures
GPIO configuration of SOC
Flex layout
How to configure DDR3 of dm8148
MySQL installation and environment variable configuration
Design and implementation of spark offline development framework
SOC clock configuration
Solving the longest palindrome substring by dynamic programming
Safety training is the greatest benefit for employees! 2022 induction safety training for new employees
asp. Net upload image path and image name
随机推荐
Online WPS tool
8 张图 | 剖析 Eureka 的首次同步注册表
Implementation of commit message standardized control in large projects
Recommended system series (Lecture 5): Optimization Practice of sorting model
[thanos source code analysis series]thanos query component source code analysis
kubelet垃圾(退出的容器和未使用的镜像)回收源码分析
安全培训是员工最大的福利!2022新员工入职安全培训全员篇
Path alias specified in vite2.9
Section Xi. Axi of zynq_ Use of DMA
goland IDE和delve调试位于kubernetes集群中的go程序
本周二晚19:00战码先锋第8期直播丨如何多方位参与OpenHarmony开源贡献
Software design of power control board
协程、asyncio、异步编程
Application of XOR. (extract the rightmost 1 in the number, which is often used in interviews)
Tencent continued to lay off staff in the second half of the year, and all business groups reduced by at least 10%. What do you think of this? Followers
HJ explicit random number
Rediscluster cluster mode capacity expansion node
HJ质数因子
ES6 use of return in arrow function
Software design of resistance test board