我在从属端遇到错误22的MySQL复制有问题,特别是关于charset错误。
错误声明它找不到charset'#45',我发现它很奇怪,因为使用的查询是DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci
,我确实检查了charset\Index.xml
它确实存在。
主人:Server version: 5.5.30-log
奴隶:Server version: 5.1.66-log
当前复制状态:
mysql> show slave status \G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 10.10.2.21
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000024
Read_Master_Log_Pos: 1065715871
Relay_Log_File: mysqld-relay-bin.000029
Relay_Log_Pos: 86980698
Relay_Master_Log_File: mysql-bin.000024
Slave_IO_Running: Yes
Slave_SQL_Running: No
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 22
Last_Error: Error 'Character set '#45' is not a compiled character set and is not specified in the '/usr/share/mysql/charsets/Index.xml' file' on query. Default database: 'db_businesslounge-backup'. Query: 'CREATE DATABASE IF NOT EXISTS `db_businesslounge-backup` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci'
Skip_Counter: 0
Exec_Master_Log_Pos: 86980553
Relay_Log_Space: 1065720589
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: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 22
Last_SQL_Error: Error 'Character set '#45' is not a compiled character set and is not specified in the '/usr/share/mysql/charsets/Index.xml' file' on query. Default database: 'db_businesslounge-backup'. Query: 'CREATE DATABASE IF NOT EXISTS`db_businesslounge-backup` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci'
MySQL的charset \ Index.xml:
<?xml version='1.0' encoding="utf-8"?>
<charsets max-id="99">
<copyright>
Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
</copyright>
<description>
This file lists all of the available character sets.
To make maintaining easier please:
- keep records sorted by collation number.
- change charsets.max-id when adding a new collation.
</description>
........
<charset name="latin1">
<family>Western</family>
<description>cp1252 West European</description>
<alias>csisolatin1</alias>
<alias>iso-8859-1</alias>
<alias>iso-ir-100</alias>
<alias>iso_8859-1</alias>
<alias>iso_8859-1:1987</alias>
<alias>l1</alias>
<alias>latin1</alias>
<collation name="latin1_german1_ci" id="5" order="German Duden"/>
<collation name="latin1_swedish_ci" id="8" order="Finnish, Swedish">
<flag>primary</flag>
<flag>compiled</flag>
</collation>
<collation name="latin1_danish_ci" id="15" order="Danish"/>
<collation name="latin1_german2_ci" id="31" order="German Phonebook" flag="compiled"/>
<collation name="latin1_spanish_ci" id="94" order="Spanish"/>
<collation name="latin1_bin" id="47" order="Binary">
<flag>binary</flag>
<flag>compiled</flag>
</collation>
<collation name="latin1_general_ci" id="48">
<order>Dutch</order>
<order>English</order>
<order>French</order>
<order>German Duden</order>
<order>Italian</order>
<order>Latin</order>
<order>Portuguese</order>
<order>Spanish</order>
</collation>
<collation name="latin1_general_cs" id="49">
<order>Dutch</order>
<order>English</order>
<order>French</order>
<order>German Duden</order>
<order>Italian</order>
<order>Latin</order>
<order>Portuguese</order>
<order>Spanish</order>
</collation>
</charset>
....
</charsets>
有没有人遇到过这个特殊错误?
需要建议,谢谢!
答案 0 :(得分:6)
您正在运行较新的主服务器和较旧的服务器。这不是受支持的配置。
http://dev.mysql.com/doc/refman/5.5/en/replication-compatibility.html
我怀疑这个错误实际上并不是关于latin1_swedish_ci,而是实际上是关于utf8mb4_general_ci,它可能在主服务器上的连接上处于活动状态,其中最初发出了无法复制的查询,因此从服务器正在尝试执行它那个背景。
我不认为这个功能(utf8mb4)存在于MySQL 5.1中,正如下面的查询所证明的那样,这也是你从不在主服务器上运行低于主服务器版本的版本的另一个原因,并且升级时,您总是希望先升级从站。
SELECT * FROM information_schema.collations WHERE id = 45
在MySQL 5.5和5.6上运行时返回一个值,但在5.1上没有。
升级从站是最正确的解决方案,但是在紧要关头,您可以直接连接到从站,自己发出完全相同的查询,如果它有效,您可以指示从站跳过该事件。中继日志,因为您已经自己执行了该查询。执行失败的查询后:
SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;
START SLAVE SQL_THREAD;
这是一项微妙的操作,只有当您完全知道自己在做什么时才适用,并且由于同样的问题,您很可能会看到后续错误,所以除非这是一个非常有益的孤立的事件。
从好的方面来说,即使在复制错误停止时升级奴隶也不理想,但它实际上成功的几率并且能够从停止复制的位置继续复制是非常好的。 / p>