MySQL使用集群提供的读写分离地址

环境:

AWS的MySQL数据库集群服务

问题描述:
MySQL数据库的master数据库,某天忽然变得没有写权限了,爆出如下错误:

### 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

问题分析:

查看数据库读写权限情况:

show global variables like "%read_only%"

结果如下:

innodb read only 

启动server 在read-only模式。对于分布在数据库应用或者数据设置为只读介质。

innodb read only 为 on, 数据库为完全只读,任何用户都无法写数据。

如果是super privilege用户设定的话,一般会设定read only的值,这样的情况下,super privilege用户还可以写数据。

问题原因:

1,AWS RDS提供了主从自动切换的功能,主数据库崩溃后,从数据库会自动选出合适的一个充当主库。2,项目没有使用RDS提供的集群读写proxy地址,而是使用了mysql实例的服务器地址,于是在主从自动切换后,指向了错误的读写服务器。

这又一个蠢到家的问题!!!

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容