当前位置:网站首页>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;
边栏推荐
- JS judge the data types object.prototype.tostring.call and typeof
- Show default image when wechat applet image cannot be displayed
- JS one line code to obtain the maximum and minimum values of the array
- Solve proxyerror: CONDA cannot proceed due to an error in your proxy configuration
- Server and client dual authentication (2)
- B站这个视频我是跪着看完的
- JS table auto cycle scrolling, mouse move in pause
- matlab中的AR模型短时预测交通流
- Write a script that can run in Bash / shell and PowerShell
- 解决IE7 & IE8 存储cookie问题
猜你喜欢
The diagram of user login verification process is well written!
[datawhale] [machine learning] Diabetes genetic risk detection challenge
Matlab Simulink realizes fuzzy PID control of time-delay temperature control system of central air conditioning
新增市场竞争激烈,中国移动被迫推出限制性超低价5G套餐
Development to testing: a six-year road to automation starting from 0
B站这个视频我是跪着看完的
2019 ICPC Asia Yinchuan regional (water problem solution)
Xiaobai makes a wave of deep copy and shallow copy
[fluorescent character effect]
Due to fierce competition in the new market, China Mobile was forced to launch a restrictive ultra-low price 5g package
随机推荐
AR model in MATLAB for short-term traffic flow prediction
图解用户登录验证流程,写得太好了!
V-for dynamically sets the SRC of img
Customize permission validation in blazor
(1) Hand eye calibration of face scanner and manipulator (eye on hand)
IE7 set overflow attribute failure solution
QT handy notes (II) edit control and float, qstring conversion
R language ggplot2 visualization: align the legend title to the middle of the legend box in ggplot2 (default left alignment, align legend title to middle of legend)
Interpretation of the standard of software programming level examination for teenagers_ second level
In the same CONDA environment, install pytroch first and then tensorflow
Double authentication of server and client
ie7设置overflow属性失效解决方法
EOJ 2020 1月月赛 E数的变换
Azkaban【基础知识 01】核心概念+特点+Web界面+架构+Job类型(一篇即可入门Azkaban工作流调度系统)
M-ary number STR to n-ary number
解决IE7 & IE8 存储cookie问题
莫队学习笔记(一)
正则表达式
Simple pedestrian recognition code to 88% accuracy Zheng Zhedong preparation
莫队学习总结(二)