简体   繁体   English

在 RDS MySQL 只读副本上创建用户

[英]Creating Users on RDS MySQL Read Replicas

Is it possible/advisable to create users that only have access to a RDS MySQL Read Replica and not to the main database server?是否可以/建议创建只能访问 RDS MySQL 只读副本而不是主数据库服务器的用户? I have a number of power users I'd like to grant access so they can run slow running queries, but don't want to give them access to the main production database itself.我有许多高级用户我想授予访问权限,以便他们可以运行运行缓慢的查询,但不想让他们访问主生产数据库本身。 Trying to do this directly on the server, I get ERROR 1290 (HY000): The MySQL server is running with the --read-only option so it cannot execute this statement , so guessing I have to do it in the db parameter group or somewhere like that.尝试直接在服务器上执行此操作,我收到ERROR 1290 (HY000): The MySQL server is running with the --read-only option so it cannot execute this statement ,因此猜测我必须在 db 参数组中ERROR 1290 (HY000): The MySQL server is running with the --read-only option so it cannot execute this statement操作或那样的地方。 Anyway, ideas?无论如何,想法?

You should not create a user only in the read replica.您不应仅在只读副本中创建用户。

It is vital for RDS to have an identical data set for both master and replica instance, so it is not possible to have a user only in the RR and not on the master (or at least inadvisable).对于 RDS 来说,对于主实例和副本实例具有相同的数据集至关重要,因此不可能只有 RR 而不是主实例(或至少是不可取的)。

A reason, besides how works the replica in RDS, is that in case of a fail-over a replica can become a master and the roles will be changed除了 RDS 中的副本如何工作之外,一个原因是在故障转移的情况下,副本可以成为主节点并且角色将发生变化

You can configure an Amazon RDS DB instance read replica to be read/write by setting the read_only parameter to false for the DB parameter group that you create for your DB instance(s).您可以通过将您为数据库实例创建的数据库参数组的 read_only 参数设置为 false 来将 Amazon RDS 数据库实例只读副本配置为读/写。

You cannot modify the parameter settings of a default DB parameter group;您不能修改默认数据库参数组的参数设置; you must create your own DB parameter group to change parameter settings from their default value.您必须创建自己的数据库参数组才能更改参数设置的默认值。

https://aws.amazon.com/premiumsupport/knowledge-center/rds-read-replica/ https://aws.amazon.com/premiumsupport/knowledge-center/rds-read-replica/

Use caution when doing this, and after you've created the users, put it back to read_only immediately.执行此操作时要小心,在创建用户后,立即将其放回 read_only。 If you ever create a user on the master with the same username/host pair on the master, replication will likely stop because this creates a conflict.如果您在 master 上创建了一个用户,在 master 上使用相同的用户名/主机对,复制可能会停止,因为这会产生冲突。

You can add or delete users in a read replica.您可以在只读副本中添加或删除用户。 This is possible by the usual way of CREATE USER .这可以通过 CREATE USER 的通常方式实现。 But this is not advisable as the read replica & master should be in sync always so if master goes-down read replica can be promoted as Master.但这不是可取的,因为只读副本和主副本应该始终保持同步,因此如果主副本出现故障,可以将只读副本提升为主副本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM