«系统:window 10 mysqld版本: 8.0.12» 从库中设置链接主库 reset slave; CHANGE MASTER TO MASTER_HOST='192.168.1.100', MASTER_USER='replication', MASTER_PASSWORD='EnterSecurePasswordHere', MASTER_PORT=3306, MASTER_AUTO_POSITION = 1; start slave; show slave status; 以上设置成功,数据同步也没问题,"mysql.slave_master_info","mysql.slave_relay_log_info"表中配置数据正常。 但是,一旦重启"slave",就报以下错误,"master"配置信息失效 [ERROR] [MY-010728] [Repl] Error writing master configuration. [ERROR] [MY-010729] [Repl] Error reading master configuration. [ERROR] [MY-013129] [Server] A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-000029 - File '.\X1C-relay-bin-@00020.index' not found (OS errno 2 - No such file or directory) [ERROR] [MY-010605] [Repl] Failed in open_index_file() called from Relay_log_info::rli_init_info(). [ERROR] [MY-010426] [Repl] Slave: Failed to initialize the master info structure for channel ' '; its record may still be present in 'mysql.slave_master_info' table, consider deleting it. [ERROR] [MY-013123] [Repl] Slave I/O for channel ' ': Slave failed to initialize master info structure from the repository, Error_code: MY-013123 [ERROR] [MY-013129] [Server] A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-001871 - Slave failed to initialize master info structure from the repository [ERROR] [MY-011025] [Repl] Failed to start slave threads for channel ' '. [System] [MY-010931] [Server] C:\mysql\Extensions\MySQL8.0.12\\bin\mysqld.exe: ready for connections. Version: '8.0.12' socket: '' port: 3306 MySQL Community Server - GPL. 更让我不理解的是 ,重启后马上执行 "show slave status;"显示下面信息: +----------------+---------------------------------------------------------------------------+-------------+-------------+---------------+ | Slave_IO_State | Master_Host | Master_User | Master_Port | Connect_Retry | +----------------+---------------------------------------------------------------------------+-------------+-------------+---------------+ | | 192.168.1.100 replication | | 3306 | 60 | +----------------+---------------------------------------------------------------------------+-------------+-------------+---------------+ "Master_Host" 字段中,混杂了 "master"的IP和用户名,中间有大量空格,而"Master_User"字段为空,令我不解 *** 在我google的时候,看到有人说是 "master.info"问题,但我并没有配置 "master-info-file",且mysql 8.0开始,已经默认是"master_info_repository=TABLE" 和 "relay_log_info_repository=TABLE",参考:"17.2.4.2 Replication Metadata Repositories" (https://link.segmentfault.com/?enc=pTorkpxRsHgfmE3cohOBJg%3D%3D.8WCuleBtENkNCaGw3WmIqaAUYBU6r6VSWYg8ALqWyu7CNe%2F8OufMKibTq8mfw04Qg45ZWtrEXZzz5IVggIETbVviqRquMtttVT4iArdX0EE%3D)
mysql重启完服务,会重新生成mysql-bin日志文件,这会导致从服务节点同步失败,必须手动重新指定File和Position,才能使从库正常运行。当然我想到的办法是写一个py脚本定时去做比较代替人工,如果mysql有相关的设置是最好的
怎样从当前数据库的状态来判断是否需要读写分离,最好经验丰富的老师来回答下。 我当前想到的是,是否可以通过 QPS/TPS 的值来判断呢?