当前位置:网站首页>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;
边栏推荐
- MQTT X CLI 正式发布:强大易用的 MQTT 5.0 命令行工具
- Learning notes: what are the common array APIs that change the original array or do not change the original array?
- Gauss elimination for solving XOR linear equations
- 正则表达式
- copyTo
- Unstoppable, pure domestic PCs have been in place, and the monopoly of the U.S. software and hardware system has been officially broken
- Node memory overflow and V8 garbage collection mechanism
- 云原生(三十六) | Kubernetes篇之Harbor入门和安装
- Double authentication of server and client
- R语言ggplot2可视化: 将图例标题(legend title)对齐到ggplot2中图例框的中间(默认左对齐、align legend title to middle of legend)
猜你喜欢

uni-app学习总结

2022年中科磐云——服务器内部信息获取 解析flag

CSV data file settings of JMeter configuration components

R语言ggplot2可视化: 将图例标题(legend title)对齐到ggplot2中图例框的中间(默认左对齐、align legend title to middle of legend)

服务器、客户端双认证(2)

正则表达式

Node 内存溢出及V8垃圾回收机制

regular expression

【Datawhale】【机器学习】糖尿病遗传风险检测挑战赛

Alibaba cloud technology expert haochendong: cloud observability - problem discovery and positioning practice
随机推荐
高斯消元求解矩阵的逆(gauss)
服务器环境配置全过程
Antd treeselect gets the value of the parent node
Spolicy request case
解决npm -v突然失效 无反应
RMQ学习笔记
在Blazor 中自定义权限验证
Mo team learning notes (I)
云原生(三十六) | Kubernetes篇之Harbor入门和安装
Sqoop【付诸实践 02】Sqoop1最新版 全库导入 + 数据过滤 + 字段类型支持 说明及举例代码(query参数及字段类型强制转换)
The combination of officially issued SSL certificate and self signed certificate realizes website two-way authentication
面试突击68:为什么 TCP 需要 3 次握手?
Gauss elimination solves the inverse of matrix (Gauss)
一种分布式深度学习编程新范式:Global Tensor
2019 ICPC Asia Yinchuan regional (water problem solution)
QT随手笔记(六)——更新界面、截图、文件对话框
JS 一行代码 获取数组最大值与最小值
POJ 1012 Joseph
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)
IIS error prompt after installing Serv-U: hresult:0x80070020