当前位置:网站首页>Mysql5.7.25 master-slave replication (one-way)
Mysql5.7.25 master-slave replication (one-way)
2022-07-26 09:49:00 【Color the sky】
mount this database :https://blog.csdn.net/u010533511/article/details/88033637
Master To configure
1)my.cnf To configure
vim /etc/my.cnf
[mysqld]
log-bin=mysql-bin //[ must ] Enable binary logging
server-id=139 //[ must ] The server is unique ID, The default is 1, Usually take IP The last paragraph
binlog-do-db=ztong # Specify the database that needs logging
binlog_format= MIXED #binlog Log format ,mysql By default statement, It is recommended to use mixed
slave_skip_errors = 1062 # Skip primary key conflict error
2) restart mysql
service mysqld restart
3) Set up an account on the primary server and authorize slave
#mysql –u root –p 123456
mysql>GRANT REPLICATION SLAVE ON *.* to 'mysync'@'%' identified by '123456';
// Generally do not use root Account number ,“%” Indicates that all clients may be connected to , Just account number , The password is correct , Specific clients are available here IP Instead of , Such as 192.168.135.139, Enhance security .
4) Sign in mysql, Inquire about master The state of
mysql>show master status;
mysql> show master status;
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000010 | 591 | ztong | | |
notes : Do not operate the master server after this step MYSQL, Prevent the state value of the primary server from changing .
File: mysql-bin.000010 Position: 591 These two values will be used later
Slave To configure
1)my.cnf To configure
vim /etc/my.cnf
[mysqld]
log-bin=mysql-bin //[ must ] Enable binary logging
server-id=141 //[ must ] The server is unique ID, The default is 1, Usually take IP The last paragraph
2) restart mysql
service mysql restart
3) Configure slave Slave:
# Database replication synchronization statement master_log_file: Corresponding master Of file
#master_log_pos: Yes master The location of the log file corresponds to master Of position
mysql> change master to master_host='192.168.135.139',master_port=3306,master_user='mysync',master_password='123456',master_log_file='mysql-bin.000010',master_log_pos=591;
mysql> start slave; // Start copy from server
4) Check the status of the copy function from the server :
mysql> show slave status\G;
mysql> show slave status \G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.135.139
Master_User: mysync
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000010
Read_Master_Log_Pos: 591 // In the current primary server binary log ,SLAVE Medium I/O Where the thread has read
Relay_Log_File: localhost-relay-bin.000002
Relay_Log_Pos: 320 // In the current relay log ,SQL Where the thread has read and executed
Relay_Master_Log_File: mysql-bin.000010
Slave_IO_Running: Yes //I/O Whether the thread is started and successfully connected to the main server
Slave_SQL_Running: Yes //SQL Whether the thread is started
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: 591
Relay_Log_Space: 531
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 // From the server SQL Thread and server I/O The time gap between threads , Unit in seconds
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: 139
Master_UUID: 383b83a3-3b1f-11e9-986d-000c295d359a
Master_Info_File: /data/mysql/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 0
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
1 row in set (0.00 sec)
Slave_IO_Running: Yes Responsible for communication with the host io signal communication
Slave_SQL_Running: Yes Be responsible for your own slave mysql process
All are yes Explain normal
test : Link to the database , Create database ztong , Create a test table
If you need to reconfigure the slave Library
mysql> slave stop
mysql> change master to master_host='192.168.135.139',master_port=3306,master_user='mysync',master_password='123456',master_log_file='mysql-bin.000010',master_log_pos=591;
mysql> start slave;
边栏推荐
- POJ 1012 Joseph
- Malloc failed to allocate space and did not return null
- matlab中的AR模型短时预测交通流
- B站这个视频我是跪着看完的
- 高斯消元求解矩阵的逆(gauss)
- What is the principle of reflection mechanism?
- Matlab Simulink realizes fuzzy PID control of time-delay temperature control system of central air conditioning
- 【荧光字效果】
- Write a script that can run in Bash / shell and PowerShell
- Network flow learning notes
猜你喜欢
QT handy notes (III) use qtcharts to draw a line chart in VS
开发转测试:从0开始的6年自动化之路...
Unstoppable, pure domestic PCs have been in place, and the monopoly of the U.S. software and hardware system has been officially broken
AR model in MATLAB for short-term traffic flow prediction
Matlab Simulink realizes fuzzy PID control of time-delay temperature control system of central air conditioning
Node memory overflow and V8 garbage collection mechanism
I finished watching this video on my knees at station B
B站这个视频我是跪着看完的
After attaching to the process, the breakpoint displays "currently will not hit the breakpoint, and no symbols have been loaded for this document"
Interview shock 68: why does TCP need three handshakes?
随机推荐
高斯消元求解矩阵的逆(gauss)
Sqoop [environment setup 01] CentOS Linux release 7.5 installation configuration sqoop-1.4.7 resolve warnings and verify (attach sqoop 1 + sqoop 2 Latest installation package +mysql driver package res
RMQ学习笔记
高斯消元的应用
IIS error prompt after installing Serv-U: hresult:0x80070020
POJ 1012 Joseph
Use of OpenCV class
Login module use case writing
Learning notes: what are the common array APIs that change the original array or do not change the original array?
图解用户登录验证流程,写得太好了!
小白搞一波深拷贝 浅拷贝
Search module use case writing
C managed and unmanaged
一种分布式深度学习编程新范式:Global Tensor
Solve proxyerror: CONDA cannot proceed due to an error in your proxy configuration
[datawhale] [machine learning] Diabetes genetic risk detection challenge
Table extraction for opencv table recognition (2)
Mo team learning notes (I)
ie7设置overflow属性失效解决方法
2022 zhongkepan cloud - server internal information acquisition and analysis flag