当前位置:网站首页>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;
边栏推荐
- Use of OpenCV class
- 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
- Smart gourmet C language
- Antd treeselect gets the value of the parent node
- 解决ProxyError: Conda cannot proceed due to an error in your proxy configuration.
- [MySQL database] a collection of basic MySQL operations - the basis of seeing (adding, deleting, modifying, and querying)
- Show default image when wechat applet image cannot be displayed
- Modern medicine in the era of "Internet +"
- [datawhale] [machine learning] Diabetes genetic risk detection challenge
- 电机转速模糊pid控制
猜你喜欢

A new paradigm of distributed deep learning programming: Global tensor

高斯消元

Xiaobai makes a wave of deep copy and shallow copy

regular expression

【荧光字效果】

图解用户登录验证流程,写得太好了!

Node memory overflow and V8 garbage collection mechanism

Server and client dual authentication (2)

Login module use case writing

2022年中科磐云——服务器内部信息获取 解析flag
随机推荐
IIS网站配置
JS判断数据类型 Object.prototype.toString.call和typeof
(2) Hand eye calibration of face scanner and manipulator (eye out of hand: nine point calibration)
The problem of accessing certsrv after configuring ADCs
莫队学习笔记(一)
Wechat applet avatarcropper avatar clipping
[information system project manager] summary of essence of high-level series for the first time
I finished watching this video on my knees at station B
2019 ICPC Asia Yinchuan regional (water problem solution)
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)
Audio and video knowledge
学习笔记之常用数组api 改变原数组和不改变原数组的有哪些?
JS one line code to obtain the maximum and minimum values of the array
【信息系统项目管理师】初见高项系列精华汇总
A new paradigm of distributed deep learning programming: Global tensor
服务器、客户端双认证
【Mysql数据库】mysql基本操作集锦-看得会的基础(增删改查)
asp. Net using redis cache
反射机制的原理是什么?
Double authentication of server and client