MySQL使用集群提供的讀寫分離地址

環(huán)境:

AWS的MySQL數(shù)據(jù)庫(kù)集群服務(wù)

問(wèn)題描述:
MySQL數(shù)據(jù)庫(kù)的master數(shù)據(jù)庫(kù),某天忽然變得沒(méi)有寫權(quán)限了,爆出如下錯(cuò)誤:

### Cause: java.sql.SQLException: The MySQL server is running with the --read-only option so it cannot execute this statement

; uncategorized SQLException for SQL []; SQL state [HY000]; error code [1290]; The MySQL server is running with the --read-only option so it cannot execute this statement; nested exception is java.sql.SQLException: The MySQL server is running with the --read-only option so it cannot execute this statement

問(wèn)題分析:

查看數(shù)據(jù)庫(kù)讀寫權(quán)限情況:

show global variables like "%read_only%"

結(jié)果如下:

innodb read only?

啟動(dòng)server 在read-only模式。對(duì)于分布在數(shù)據(jù)庫(kù)應(yīng)用或者數(shù)據(jù)設(shè)置為只讀介質(zhì)。

innodb read only?為 on, 數(shù)據(jù)庫(kù)為完全只讀,任何用戶都無(wú)法寫數(shù)據(jù)。

如果是super privilege用戶設(shè)定的話,一般會(huì)設(shè)定read only的值,這樣的情況下,super privilege用戶還可以寫數(shù)據(jù)。

問(wèn)題原因:

1,AWS?RDS提供了主從自動(dòng)切換的功能,主數(shù)據(jù)庫(kù)崩潰后,從數(shù)據(jù)庫(kù)會(huì)自動(dòng)選出合適的一個(gè)充當(dāng)主庫(kù)。2,項(xiàng)目沒(méi)有使用RDS提供的集群讀寫proxy地址,而是使用了mysql實(shí)例的服務(wù)器地址,于是在主從自動(dòng)切換后,指向了錯(cuò)誤的讀寫服務(wù)器。

這又一個(gè)蠢到家的問(wèn)題!?。?/p>

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容