MySQL --read-only
转自:http://blog.csdn.net/cindy9902/article/details/5886355
以前在用MMM管理multi master 作failover是看到过MMM使用read-only选项来控制对其读写角色的分配,当时尝试过加上这个选项,然后对其进行update,insert操作,发现也是可以的。。所以觉得这个选项没有什么实际意义。。。现在想想当时是用管理员的帐户去执行的,肯定是有super权限的,所以才可以进行update和insert操作。
今天在测试过程中也遇到了read-only的问题,发现写操作因为read-only 这个选项的开启,而不能够成功执行。找了下资料,才了解read-only的真正含义和用法:
** –read_only** Make all non-temporary tables read-only, with the
exception for replication (slave) threads and users with
the SUPER privilege
SUPER privilege :
The SUPER
privilege enables an account to use CHANGE MASTER TO
, KILL
or mysqladmin kill to kill threads belonging to other accounts (you can always kill your own threads), PURGE BINARY LOGS
, configuration changes using SET GLOBAL
to modify global system variables, the mysqladmin debug command, enabling or disabling logging, performing updates even if the read_only
system variable is enabled, starting and stopping replication on slave servers, specification of any account in the DEFINER
attribute of stored programs and views, and enables you to connect (once) even if the connection limit controlled by the max_connections
system variable is reached.
To create or alter stored routines if binary logging is enabled, you may also need the SUPER
privilege, as described in Section 18.6, “Binary Logging of Stored Programs” .
read-only选项:对所有的非临时表进行只读控制。但是有两种情况例外:
对replication threads例外,以保证slave能够正常的进行replication。
对于拥有super权限的用户,可以ignore这个选项。
SUPER 权限 : 1. 可以有change master to, kill其他用户的线程的权限。
Purge binary logs 来删除binary log, set global来动态设置变量的权限。
执行mysqladmin debug命令,开启或者关闭log,在read-only打开时执行update/insert操作。
执行start slave, stop slave.
当连接数已经达到max_connections的最大值时,也可以连接到server。