溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶(hù)服務(wù)條款》

MySQL 5.6 GTID常見(jiàn)錯(cuò)誤的示例分析

發(fā)布時(shí)間:2021-11-06 16:35:55 來(lái)源:億速云 閱讀:253 作者:小新 欄目:MySQL數(shù)據(jù)庫(kù)

這篇文章給大家分享的是有關(guān)MySQL 5.6 GTID常見(jiàn)錯(cuò)誤的示例分析的內(nèi)容。小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過(guò)來(lái)看看吧。

在測(cè)試環(huán)境搭建完基于GTID的雙主環(huán)境后,啟動(dòng)數(shù)據(jù)庫(kù)報(bào)錯(cuò):

[root@localhost ~]# service mysqld start
Starting MySQL.........The server quit without updating PID[FAILED]usr/local/mysql/data/localhost.pid).


查看錯(cuò)誤日志/var/log/mysqld.log,發(fā)現(xiàn)有如下信息:

2017-05-11 09:08:38 56355 [Note] Audit Plugin: Init completed successfully.
2017-05-11 09:08:38 56355 [ERROR] --gtid-mode=ON or UPGRADE_STEP_1 or UPGRADE_STEP_2 requires --log-bin and --log-slave-updates
2017-05-11 09:08:38 56355 [ERROR] Aborting


說(shuō)明如下:
gtid_mode=ON,log_slave_updates,enforce_gtid_consistency這三個(gè)參數(shù)一定要同時(shí)在my.cnf中配置。否則在mysql.err中會(huì)出現(xiàn)如下的報(bào)錯(cuò)


2015-02-26 17:11:08 32147 [ERROR] --gtid-mode=ON or UPGRADE_STEP_1 or UPGRADE_STEP_2 requires --log-bin and --log-slave-updates


2015-02-26 17:13:53 32570 [ERROR] --gtid-mode=ON or UPGRADE_STEP_1 requires --enforce-gtid-consistency


修改/etc/my.cnf,加入以下內(nèi)容:
gtid-mode = on
log-slave-updates=ON
enforce-gtid-consistency=ON


再次啟動(dòng)數(shù)據(jù)庫(kù)后,再無(wú)報(bào)錯(cuò):


[root@localhost ~]# service mysqld start
Starting MySQL.....                                        [  OK  ]




[root@localhost ~]# mysql -u mdba -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.27-log Source distribution


Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.


Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.


Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


查看gtid模式:


mysql> show global variables like '%gtid%';
+---------------------------------+-------+
| Variable_name                   | Value |
+---------------------------------+-------+
| binlog_gtid_simple_recovery     | OFF   |
| enforce_gtid_consistency        | ON    |
| gtid_executed                   |       |
| gtid_mode                       | ON    |
| gtid_owned                      |       |
| gtid_purged                     |       |
| simplified_binlog_gtid_recovery | OFF   |
+---------------------------------+-------+
7 rows in set (0.00 sec)

GTID相關(guān)參數(shù)
參數(shù)                     comment
gtid_executed           執(zhí)行過(guò)的所有GTID
gtid_purged           丟棄掉的GTID
gtid_mode           gtid模式
gtid_next           session級(jí)別的變量,下一個(gè)gtid
gtid_owned           正在運(yùn)行的gtid
enforce_gtid_consistency    保證GTID安全的參數(shù)


GTID復(fù)制的限制:
GTID 模式實(shí)例和非GTID模式實(shí)例是不能進(jìn)行復(fù)制的,要求非常嚴(yán)格,要么都是GTID,要么都不是
gtid_mode 是只讀的,要改變狀態(tài)必須1)關(guān)閉實(shí)例、2)修改配置文件、3) 重啟實(shí)例
在同一事務(wù)中更新事務(wù)表與非事務(wù)表將導(dǎo)致多個(gè)GTIDs分配給同一事務(wù)
無(wú)法使用CREATE TABLE ... SELECT statements語(yǔ)句
無(wú)法在事務(wù)中對(duì)非事務(wù)存儲(chǔ)引擎進(jìn)行更新
無(wú)法在事務(wù)中使用CREATE TEMPORARY TABLE

感謝各位的閱讀!關(guān)于“MySQL 5.6 GTID常見(jiàn)錯(cuò)誤的示例分析”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,讓大家可以學(xué)到更多知識(shí),如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI