原来看过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 statusG 
*************************** 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 statusG 
*************************** 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) 
确认以上信息和主服务器是否一致。
mysql主从服务器同步心得体会第1/2页
时间:2024-3-1 22:31 作者:韩俊 分类: Mysql
标签: mysql