2015年4月8日主从不同步故障解决(字符集导致)
????1、現(xiàn)狀 :服務(wù)器A 從庫(kù);????
????????????? 服務(wù)器B 主庫(kù);
????????????? 關(guān)系:主從同步
????2、現(xiàn)添加一臺(tái)服務(wù)器C為主庫(kù),同步服務(wù)器A---》同步服務(wù)器B
操作1、停止 /etc/init.d/xa-anaxxx-tomcat? stop?? 主從同步分析停止 ;
????2、停止 /etc/init.d/xa-colxxx-tomcat? stop?? 數(shù)據(jù)插入主庫(kù)停止;
??? 3、MQ查看正常;
????4、停止服務(wù)器B 同步 stop slave ;
????5、確認(rèn)server-id 值是唯一;
????6、在服務(wù)器C創(chuàng)建A同步賬號(hào);
?????? #注意:創(chuàng)建的賬號(hào)為字母+數(shù)字;
????7、在服務(wù)器A 上change master to .....
????8、在服務(wù)器A SHOW SLAVE STATUS\G
?????? Last_IO_Errno: 1045 Last_IO_Error: error connecting to master
???????? 排查:檢查端口、網(wǎng)絡(luò)是否暢通,(iptables)
???????????? ? 檢查賬號(hào)、密碼是否正確,(空格檢查)
?????????????? 檢查pos點(diǎn)是否正確;
????? 9、上述確認(rèn)無(wú)誤后,檢查服務(wù)器(從庫(kù))C 錯(cuò)誤日志
???????? 提示:? 未禁用DNS解析
?????????? 導(dǎo)致: ? 遠(yuǎn)程訪問(wèn)慢
?????????? 解決: ?在[mysqld] 添加:skip-name-resolve?
????????????????#不再進(jìn)行反解析(ip不反解成域名),這樣可以加快數(shù)據(jù)庫(kù)的反應(yīng)時(shí)間
???????? 報(bào)錯(cuò):? ignored in --skip-name-resolve mode.”Warning? (未處理)
????????? 優(yōu)化方法:http://bbs.51cto.com/thread-1062614-1-1.html?
???? 10、再次change master to? 報(bào)錯(cuò)無(wú)法同步;
???? 11、在服務(wù)器C重新創(chuàng)建賬號(hào)(字母+數(shù)字)且授權(quán)all 權(quán)限 10.2.24.%網(wǎng)段同步;
???? 12、在服務(wù)器A 嘗試用服務(wù)器C創(chuàng)建的賬號(hào)登陸,且無(wú)法登陸;
???? 13、檢查字符集: show variables? like "%char%";
???????????? slave1
????| character_set_client???? | utf8???????????????????????????? |
????| character_set_connection | utf8???????????????????????????? |
????| character_set_database?? | latin1?????????????????????????? |
????| character_set_filesystem | binary?????????????????????????? |
????| character_set_results??? | utf8???????????????????????????? |
????| character_set_server???? | latin1?????????????????????????? |
????| character_set_system???? | utf8???????????????????????????? |
????| character_sets_dir?????? | /usr/local/mysql/share/charsets/ |
????????????master
????| character_set_client???? | latin1??????????????????????????????????? |客戶(hù)端字符集
????| character_set_connection | latin1??????????????????????????????????? |鏈接數(shù)據(jù)庫(kù)字符集
????| character_set_database?? | utf8????????????????????????????????????? |數(shù)據(jù)庫(kù)服務(wù)器中字符集使用
????| character_set_filesystem | binary??????????????????????????????????? |
????| character_set_results??? | latin1??????????????????????????????????? |數(shù)據(jù)庫(kù)給客戶(hù)端返回時(shí)使用的字符集設(shè)定
????| character_set_server???? | utf8????????????????????????????????????? |服務(wù)器安裝時(shí)指定的字符集設(shè)定
????| character_set_system???? | utf8????????????????????????????????????? |數(shù)據(jù)庫(kù)系統(tǒng)使用的字符集設(shè)定
????| character_sets_dir?????? | /application/mysql-5.5.19/share/charsets/ |
?????? 原因分析:由于數(shù)據(jù)庫(kù)字符集不一致導(dǎo)致,導(dǎo)致創(chuàng)建的賬號(hào)在遠(yuǎn)程登陸的時(shí)候無(wú)法識(shí)別;
?????? 服務(wù)器A配置文件修改: #一般使用utf8
????????[client]
????????default-character-set=utf8
????????[mysqld]
????????character-set-server=utf8
????????init_connect='SET NAMES utf8'
??????
???? 14、刪除原有用于同步賬號(hào),刷新權(quán)限后,查看賬號(hào)沒(méi)有刪除;
???????? use mysql ; select * from user\G;
???????? ????????????????? Host: 10.2.24.xx
????????????????? User: sxxx
?????????????? ??? Password: *D26AD47137B28F4998C27561AA397B1ED3FBF0B1
?????????? ????????Select_priv: N
?????????????????? Insert_priv: N
?????????? ????????Update_priv: N
?????????? ????????Delete_priv: N
?????????? ????????Create_priv: N
????????? #賬號(hào)創(chuàng)建時(shí)權(quán)限為all ,此處查看沒(méi)有任何權(quán)限
????????? #在user 表中刪除創(chuàng)建的賬號(hào),(賬號(hào)、網(wǎng)段名稱(chēng)盡量復(fù)制黏貼系統(tǒng)查看的)
???? 15、重新創(chuàng)建賬號(hào) kong ,授權(quán)all
???????? #賬號(hào)為全字母,且為小寫(xiě)
???? 16、在服務(wù)器A? 登陸成功
???? 17、 使用新創(chuàng)建的賬號(hào)(kong) change master to 同步成功
????18、導(dǎo)入數(shù)據(jù)測(cè)試字符集是否正常
????19、如果對(duì)已有的表無(wú)法進(jìn)行操作(字符集導(dǎo)致),刪除表結(jié)構(gòu)重新創(chuàng)建。
??????? #可以到相對(duì)應(yīng)的數(shù)據(jù)文件中刪除相對(duì)應(yīng)的表名
????20、重新建庫(kù)、建表、導(dǎo)入數(shù)據(jù)測(cè)試、同步........
經(jīng)驗(yàn)提示:mysql數(shù)據(jù)庫(kù)中表名區(qū)分大小寫(xiě)
?? 修改: [mysqld]? #注意重啟
?????????lower_case_table_names=1?
???????? #lower_case_table_names=1(1是不區(qū)分大小寫(xiě),0是區(qū)分)
???????
大小寫(xiě)區(qū)分提示:http://www.linuxidc.com/Linux/2007-12/9831.htm?
轉(zhuǎn)載于:https://blog.51cto.com/linuxboys/1630120
總結(jié)
以上是生活随笔為你收集整理的2015年4月8日主从不同步故障解决(字符集导致)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: LoadRunner的Socket脚本关
- 下一篇: PHP ServerPush (推送)