最近在部署MySQL主從複製架構的時候,碰到了"Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave have equal My 錯誤提示。即主從架構中使用了相同的UUID。檢查server_id系統變量,已經是不同的設置,那原因是?接下來為具體描述。
1、错误消息 mysql> show slave staus; Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server UUIDs; these UUIDs must be different for replication to work. 2、查看主从的server_id变量 master_mysql> show variables like 'server_id'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | server_id | 33 | +---------------+-------+ slave_mysql> show variables like 'server_id'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | server_id | 11 | +---------------+-------+ -- 从上面的情形可知,主从mysql已经使用了不同的server_id 3、解决故障 ###查看auto.cnf文件 [root@dbsrv1 ~] cat /data/mysqldata/auto.cnf ### 主上的uuid [auto] server-uuid=62ee10aa-b1f7-11e4-90ae-080027615026 [root@dbsrv2 ~]# more /data/mysqldata/auto.cnf ###从上的uuid,果然出现了重复,原因是克隆了虚拟机,只改server_id不行 [auto] server-uuid=62ee10aa-b1f7-11e4-90ae-080027615026 [root@dbsrv2 ~]# mv /data/mysqldata/auto.cnf /data/mysqldata/auto.cnf.bk ###重命名该文件 [root@dbsrv2 ~]# service mysql restart ###重启mysql Shutting down MySQL.[ OK ] Starting MySQL.[ OK ] [root@dbsrv2 ~]# more /data/mysqldata/auto.cnf ###重启后自动生成新的auto.cnf文件,即新的UUID [auto] server-uuid=6ac0fdae-b5d7-11e4-a9f3-0800278ce5c9 ###再次查看slave的状态已经正常 [root@dbsrv1 ~]# mysql -uroot -pxxx -e "show slave status\G"|grep Running Warning: Using a password on the command line interface can be insecure. Slave_IO_Running: Yes Slave_SQL_Running: Yes Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it ###主库端查看自身的uuid master_mysql> show variables like 'server_uuid'; +---------------+--------------------------------------+ | Variable_name | Value | +---------------+--------------------------------------+ | server_uuid | 62ee10aa-b1f7-11e4-90ae-080027615026 | +---------------+--------------------------------------+ 1 row in set (0.00 sec) ###主库端查看从库的uuid master_mysql> show slave hosts; +-----------+------+------+-----------+--------------------------------------+ | Server_id | Host | Port | Master_id | Slave_UUID | +-----------+------+------+-----------+--------------------------------------+ | 33 | | 3306 | 11 | 62ee10aa-b1f7-11e4-90ae-080027615030 | | 22 | | 3306 | 11 | 6ac0fdae-b5d7-11e4-a9f3-0800278ce5c9 | +-----------+------+------+-----------+--------------------------------------+ ### Author : Leshami ### Blog : http://www.php.cn/
4、延生參考
a、有關server_id的描述
The server ID, used in replication to give each master and slave a unique identity. This 集. option. For each server participating in replication, you should pick a
positive integer in the range from 1 to 232– 1(2的32次方減1) to act as that server's ID.
、有關server_uuid的描述Beginning with MySQL 5.6, the server generates a true UUID in addition to the --server-id
supplied by the user.This is available as the global, server-on vhariableuu只讀變數)
When starting, the MySQL server automatically obtains a UUID as follows:a). Attempt to read and use the UUID written in the data_dir/hersserverf (dir/Ffilethe)f (dir/profilef. ); exit on success.b). Otherwise, generate a new UUID and save it to this file, creating the file if necessary.The auto.cnf file has a format similar to that used for my.that used for my.finior used for my. files. In MySQL 5.6,
value;
automatically generated; you should not attempt to write
or modify this file
Also beginning with MySQL 5.6, when snows SQL SQL dowues 完成. s UUID can be seen in the output of SHOW SLAVE HOSTS. OnceSTART SLAVE has been executed (but not before), the value of the master's UUID is available on the
slave in the output of SHOW SLAVE STATUS.A5,7. later, a server's server_uuid is also used in GTIDs for transactions originating
on that server. For more information, see Section 16.1.3, “Replication with Global Transaction
的上述內容,以上是更多內容。相關內容請關注PHP中文網(www.php.cn)!

存儲過程是MySQL中的預編譯SQL語句集合,用於提高性能和簡化複雜操作。 1.提高性能:首次編譯後,後續調用無需重新編譯。 2.提高安全性:通過權限控制限制數據表訪問。 3.簡化複雜操作:將多條SQL語句組合,簡化應用層邏輯。

MySQL查詢緩存的工作原理是通過存儲SELECT查詢的結果,當相同查詢再次執行時,直接返回緩存結果。 1)查詢緩存提高數據庫讀取性能,通過哈希值查找緩存結果。 2)配置簡單,在MySQL配置文件中設置query_cache_type和query_cache_size。 3)使用SQL_NO_CACHE關鍵字可以禁用特定查詢的緩存。 4)在高頻更新環境中,查詢緩存可能導致性能瓶頸,需通過監控和調整參數優化使用。

MySQL被廣泛應用於各種項目中的原因包括:1.高性能與可擴展性,支持多種存儲引擎;2.易於使用和維護,配置簡單且工具豐富;3.豐富的生態系統,吸引大量社區和第三方工具支持;4.跨平台支持,適用於多種操作系統。

MySQL數據庫升級的步驟包括:1.備份數據庫,2.停止當前MySQL服務,3.安裝新版本MySQL,4.啟動新版本MySQL服務,5.恢復數據庫。升級過程需注意兼容性問題,並可使用高級工具如PerconaToolkit進行測試和優化。

MySQL備份策略包括邏輯備份、物理備份、增量備份、基於復制的備份和雲備份。 1.邏輯備份使用mysqldump導出數據庫結構和數據,適合小型數據庫和版本遷移。 2.物理備份通過複製數據文件,速度快且全面,但需數據庫一致性。 3.增量備份利用二進制日誌記錄變化,適用於大型數據庫。 4.基於復制的備份通過從服務器備份,減少對生產系統的影響。 5.雲備份如AmazonRDS提供自動化解決方案,但成本和控制需考慮。選擇策略時應考慮數據庫大小、停機容忍度、恢復時間和恢復點目標。

MySQLclusteringenhancesdatabaserobustnessandscalabilitybydistributingdataacrossmultiplenodes.ItusestheNDBenginefordatareplicationandfaulttolerance,ensuringhighavailability.Setupinvolvesconfiguringmanagement,data,andSQLnodes,withcarefulmonitoringandpe

在MySQL中優化數據庫模式設計可通過以下步驟提升性能:1.索引優化:在常用查詢列上創建索引,平衡查詢和插入更新的開銷。 2.表結構優化:通過規範化或反規範化減少數據冗餘,提高訪問效率。 3.數據類型選擇:使用合適的數據類型,如INT替代VARCHAR,減少存儲空間。 4.分區和分錶:對於大數據量,使用分區和分錶分散數據,提升查詢和維護效率。

tooptimizemysqlperformance,lofterTheSeSteps:1)inasemproperIndexingTospeedUpqueries,2)使用ExplaintplaintoAnalyzeandoptimizequeryPerformance,3)ActiveServerConfigurationStersLikeTlikeTlikeTlikeIkeLikeIkeIkeLikeIkeLikeIkeLikeIkeLikeNodb_buffer_pool_sizizeandmax_connections,4)


熱AI工具

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

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

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

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

熱門文章

熱工具

mPDF
mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),

PhpStorm Mac 版本
最新(2018.2.1 )專業的PHP整合開發工具

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

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

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