mysql主从服务器同步心得体会第1/2页
时间:2024-01-18 13:34:20
原来看过MYSQL同步数据的实现,可是自己还没有动过手,今天没什么事就玩一玩,正好在旁边有另一台空电脑,都在同一个路由器下。哈哈,正好。
不过首先在找配置文件上就把我卡了好久,由于我用的是xampp安装包,在xampp/mysql/bin目录下看始终没有找到my.cnf,在c:windows目录下也没有发现,
如上图,看到的只有一个”my”的快速拨号的东西,又不是文件,怎么都打不开。后来找了好久才在网上看到说遇到这种情况需要先打开editplus,然后再从editplus里面打开这个文件,果然。。。
配置就不详说了,网上有很多,我原来也转过一篇。
今天主要是讲一下配置主从服务器需要注意的地方:
首先需要做主从的数据库必须一模一样,如果你的数据库已经运行过一段时间,建议你先删除所有的二进制日志文件,包括索引xxx.index这个文件,否则重启mysql会出错。
从服务器上已经删除掉所有的二进制日志文件,当然包括一个master.info这个文件。这个文件是用来记录主服务器上过来的日志文件和记录位置的。如果你不删除它,它还会按照之前的记录来做,所以会出问题,我在这里浪费了很多时间了。
主服务器诊断:
show processlist;显示所有的进程。
show master status;显示主服务器的日志文件和指针位置。
mysql> show master status;
+——————+———-+—————-+——————+
File Position Binlog_Do_DB Binlog_Ignore_DB
+——————+———-+—————-+——————+
mysql-bin.000001 603 videoCommunity
+——————+———-+—————-+——————+
1 row in set (0.00 sec)
mysql> show master status\G
*************************** 1. row ***************************
File: mysql-bin.000001
Position: 603
Binlog_Do_DB: videoCommunity
Binlog_Ignore_DB:
1 row in set (0.00 sec)
如上图,mysql-bin.000001是日志记录文件,603是指针位置。
从服务器(slave)上诊断:
mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: master1
Master_User: root
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 603
Relay_Log_File: master2-relay-bin.000053
Relay_Log_Pos: 740
Relay_Master_Log_File: mysql-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB: videoCommunity
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: 603
Relay_Log_Space: 740
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
1 row in set (0.00 sec)
确认以上信息和主服务器是否一致。
12下一页阅读全文
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
vue中el-table合并列的具体实现
![](https://img.aspxhome.com/file/2023/0/130230_0s.png)
先学会为自己做设计
ASP基础教程:常用的 ASP ActiveX 组件
![](https://img.aspxhome.com/file/UploadPic/200812/20081213132956582.gif)
CSS content, counter-increment 和 counter-reset详解[译]
Python闭包之返回函数的函数用法示例
![](https://img.aspxhome.com/file/2023/5/101195_0s.png)
基于javascript实现表格的简单操作
python实现远程通过网络邮件控制计算机重启或关机
![](https://img.aspxhome.com/file/2023/9/110599_0s.jpg)
python 实现将txt文件多行合并为一行并将中间的空格去掉方法
python实现在sqlite动态创建表的方法
Asp用正则表达式获取文章中的所有图片地址
asp.net连接数据库读取数据示例分享
Pytest fixture及conftest相关详解
![](https://img.aspxhome.com/file/2023/0/134470_0s.png)
python批量下载图片的三种方法
利用 Python 实现多任务进程
![](https://img.aspxhome.com/file/2023/2/93882_0s.png)
JavaScript基于setTimeout实现计数的方法
python3 pathlib库Path类方法总结
Python时间处理模块Time和DateTime
![](https://img.aspxhome.com/file/2023/3/63563_0s.jpg)
详解Python中的 type()函数
Vue项目中props传值时子组件检测不到的问题及解决
![](https://img.aspxhome.com/file/2023/9/123129_0s.jpg)
python控制台打印log输出重复的解决方法
![](https://img.aspxhome.com/file/2023/8/105578_0s.jpg)