当前位置:网站首页>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
边栏推荐
猜你喜欢

Sword finger offer|: linked list (simple)

Source code analysis of kubernetes' process of deleting pod

Software design of power control board

Resizing node of rediscluster cluster cluster mode

Airflow2.1.1 ultra detailed installation document

How to configure DDR3 of dm8148

Design of DSP image data stream

Kubelet garbage collection (exiting containers and unused images) source code analysis

es6箭头函数中return的用法

Safety training is the greatest benefit for employees! 2022 induction safety training for new employees
随机推荐
Makefile
Open62541 import nodeset file directly
HJ质数因子
QT -- communication protocol
同花顺注册开户靠谱吗?安全吗?
Implementation of commit message standardized control in large projects
Introduction and several months' experience of extending the solution thanos of Prometheus
Study notes 22/1/17
PLC -- Notes
flex布局
基金的投资交易与结算
ES6 use of return in arrow function
Ambari (VI) -- ambari API use
ACM笔记
Sword finger offer|: linked list (simple)
Hash slot of rediscluster cluster cluster implementation principle
Is it safe to open an account on Dongfang fortune
Kubernetes cluster command line tool kubectl
asp. Net registration page
7-1 understand everything