bitsCN.com
mysql_upgrade引起的master/slave replication中断解决
在生产环境master服务器上处理完《1548-Cannot loadfrom mysql.proc. The table is probably corrupted》后,接到报警信息,slave服务器复制中断查看slave 状态
mysql>show slave status
发现如下语句执行错误
DROP DATABASEIF EXISTS performance_schema
performance_schema是mysql自带的性能信息相关的库,mysql怎么会执行这个操作,看看错误日志吧
[root@db25522]# tail -n 500/data/my2/mysql/db25522.err
13051310:29:54 [Note] Error reading relay log event: slave SQL thread was killed
13051310:29:54 [ERROR] Error reading packet from server: Lost connection to MySQLserver during query ( server_errno=2013)
13051310:29:54 [Note] Slave I/O thread killed while reading event
13051310:29:54 [Note] Slave I/O thread exiting, read up to log 'mysql-bin.002734',position 1017737307
13051310:29:57 [Note] Slave I/O thread: connected to master 'repl@xxx.xxx.xxx.xxx:3306',replicationstarted in log 'mysql-bin.002734' at position 1017737307
13051310:29:57 [Note] Slave SQL thread initialized, starting replication in log'mysql-bin.002734' at position 1017729051, relay log'/my/rlog/relay-bin.000764' position: 1017729197
13053015:00:53 [ERROR] Incorrect definition of table mysql.proc: expected column'comment' at position 15 to have type text, found type char(64).
13053015:00:53 [ERROR] Slave SQL: Query caused differenterrors on master and slave. Error on master: message (format)='Cannot load from mysql.%s. The tableis probably corrupted' error code=1548 ; Error on slave: actual message='noerror', error code=0. Default database: 'performance_schema'. Query: 'DROP DATABASE IF EXISTS performance_schema',Error_code: 0
13053015:00:53 [Warning] Slave: Cannot load from mysql.proc. The table is probablycorrupted Error_code: 1548
13053015:00:53 [ERROR] Error running query, slave SQL thread aborted. Fix theproblem, and restart the slave SQL thread with "SLAVE START". We stoppedat log 'mysql-bin.002947' position 721651903
莫非是数据不一致导致的?发现master服务器有performance_schema这个库,但是slave服务器没有。在执行 mysql_upgrade -uroot 之前,主从复制在运行,判断操作发生在mysql_upgrade-uroot之后,分析master上日志,在这个时间段内mysql进行了那些操作
[root@db25522]# mysqlbinlog --no-defaults --start-date='2013-05-3015:00:00' --end-date='2013-05-3015:03:00' mysql-bin.002947 >/root/tmp.log
查询日志发现
[root@db25522]#vi /root/tmp.log
/DROP
/*!*/;
# at721651876
#13053015:00:25 server id 13084 end_log_pos721651903 Xid = 435509540
COMMIT/*!*/;
# at 721651903
#13053015:00:53 server id 13084 end_log_pos721652022 Query thread_id=418930 exec_time=0 error_code=1548
SETTIMESTAMP=1369897253/*!*/;
/*!/Cutf8 *//*!*/;
SET@@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=28/*!*/;
DROP DATABASE IF EXISTS performance_schema
/*!*/;
# at721652022
#13053015:00:53 server id 13084 end_log_pos721652152 Query thread_id=418930 exec_time=0 error_code=0
SETTIMESTAMP=1369897253/*!*/;
CREATEDATABASE performance_schema character set utf8
/*!*/;
# at721652152
#13053015:03:19 server id 13084 end_log_pos721652223 Query thread_id=418956 exec_time=0 error_code=0
SETTIMESTAMP=1369897399/*!*/;
/*!/Cgbk *//*!*/;
SET@@session.character_set_client=28,@@session.collation_connection=28,@@session.collation_server=28/*!*/;
BEGIN
/*!*/;
# at721652223
#13053015:03:19 server id 13084 end_log_pos721652336 Query thread_id=418956 exec_time=0 error_code=0
usePriceDB/*!*/;
SETTIMESTAMP=1369897399/*!*/;
好吧,上面红色部分,执行了这个操作,再看看slave错误日志
13053015:00:53 [ERROR] Incorrect definition of table mysql.proc: expected column'comment' at position 15 to have type text, found type char(64).
13053015:00:53 [ERROR] Slave SQL: Query caused different errors on master andslave. Error on master: message(format)='Cannot load from mysql.%s. The table is probably corrupted' errorcode=1548 ; Error on slave: actual message='no error', error code=0. Defaultdatabase: 'performance_schema'. Query: 'DROP DATABASE IF EXISTSperformance_schema', Error_code: 0
13053015:00:53 [Warning] Slave: Cannot load from mysql.proc. The table is probablycorrupted Error_code: 1548
13053015:00:53 [ERROR] Error running query, slave SQL thread aborted. Fix the problem,and restart the slave SQL thread with "SLAVE START". We stopped atlog 'mysql-bin.002947' position 721651903
5.5的日志错误还是很人性化的,slave停止时读取的binlog 日志文件,位置都很清楚。这为我们restart slave提供了方便。既然是DROP DATABASE IFEXISTS performance_schema 导致的错误,那么跳过这条event。
Slave服务器:
mysql>show variables like '%skip%';
mysql>setglobal sql_slave_skip_counter =1;
mysql>slave start ;
复制正常
总结:复制虽然正常了。为什么 mysql_upgrade 会做 DROP DATABASE IF EXISTSperformance_schema 这个操作?希望遇到类似问题的朋友,一起交流。
bitsCN.com
如何有效監控MySQL性能?使用mysqladmin、SHOWGLOBALSTATUS、PerconaMonitoringandManagement(PMM)和MySQLEnterpriseMonitor等工具。 1.使用mysqladmin查看連接數。 2.用SHOWGLOBALSTATUS查看查詢數。 3.PMM提供詳細性能數據和圖形化界面。 4.MySQLEnterpriseMonitor提供豐富的監控功能和報警機制。

MySQL和SQLServer的区别在于:1)MySQL是开源的,适用于Web和嵌入式系统,2)SQLServer是微软的商业产品,适用于企业级应用。两者在存储引擎、性能优化和应用场景上有显著差异,选择时需考虑项目规模和未来扩展性。

在需要高可用性、高級安全性和良好集成性的企業級應用場景下,應選擇SQLServer而不是MySQL。 1)SQLServer提供企業級功能,如高可用性和高級安全性。 2)它與微軟生態系統如VisualStudio和PowerBI緊密集成。 3)SQLServer在性能優化方面表現出色,支持內存優化表和列存儲索引。

mySqlManagesCharacterSetsetSandCollationsyutusututf-8asthEdeFault,允許ConfigurationAtdataBase,table和columnlevels,AndrequiringCarefullageLignmentToavoidMismatches.1)setDefeaultCharactersetTercharactersetEtCollacterSeteTandColletationForAdataBase.2)conformentcollecharactersettersetertersetcollatertersetcollationcollation

MySQL觸發器是與表相關聯的自動執行的存儲過程,用於在特定數據操作時執行一系列操作。 1)觸發器定義與作用:用於數據校驗、日誌記錄等。 2)工作原理:分為BEFORE和AFTER,支持行級觸發。 3)使用示例:可用於記錄薪資變更或更新庫存。 4)調試技巧:使用SHOWTRIGGERS和SHOWCREATETRIGGER命令。 5)性能優化:避免複雜操作,使用索引,管理事務。

在MySQL中創建和管理用戶賬戶的步驟如下:1.創建用戶:使用CREATEUSER'newuser'@'localhost'IDENTIFIEDBY'password';2.分配權限:使用GRANTSELECT,INSERT,UPDATEONmydatabase.TO'newuser'@'localhost';3.修正權限錯誤:使用REVOKEALLPRIVILEGESONmydatabase.FROM'newuser'@'localhost';然後重新分配權限;4.優化權限:使用SHOWGRA

MySQL適合快速開發和中小型應用,Oracle適合大型企業和高可用性需求。 1)MySQL開源、易用,適用於Web應用和中小型企業。 2)Oracle功能強大,適合大型企業和政府機構。 3)MySQL支持多種存儲引擎,Oracle提供豐富的企業級功能。

MySQL相比其他關係型數據庫的劣勢包括:1.性能問題:在處理大規模數據時可能遇到瓶頸,PostgreSQL在復雜查詢和大數據處理上表現更優。 2.擴展性:水平擴展能力不如GoogleSpanner和AmazonAurora。 3.功能限制:在高級功能上不如PostgreSQL和Oracle,某些功能需要更多自定義代碼和維護。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

ZendStudio 13.5.1 Mac
強大的PHP整合開發環境

SAP NetWeaver Server Adapter for Eclipse
將Eclipse與SAP NetWeaver應用伺服器整合。

DVWA
Damn Vulnerable Web App (DVWA) 是一個PHP/MySQL的Web應用程序,非常容易受到攻擊。它的主要目標是成為安全專業人員在合法環境中測試自己的技能和工具的輔助工具,幫助Web開發人員更好地理解保護網路應用程式的過程,並幫助教師/學生在課堂環境中教授/學習Web應用程式安全性。 DVWA的目標是透過簡單直接的介面練習一些最常見的Web漏洞,難度各不相同。請注意,該軟體中

VSCode Windows 64位元 下載
微軟推出的免費、功能強大的一款IDE編輯器

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)