Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: 当TIDB作为mysql从库时如何配置为只读模式
[TiDB Usage Environment] Production Environment
[TiDB Version] v6.1.0
[Encountered Problem]
Currently, my TiDB cluster is configured as a replica using the DM component, with MySQL 5.7 as the upstream. Now I want to configure TiDB as a read-only replica. How can I achieve this? It seems that setting read_only results in an error?
[Reproduction Path] What operations were performed that led to the problem
[Problem Phenomenon and Impact]
mysql> set global read_only = 1;
ERROR 1235 (42000): function READ ONLY has only noop implementation in tidb now, use tidb_enable_noop_functions to enable these functions
mysql>
mysql>
Additionally, do I need to enable this variable (tidb_enable_noop_functions
)?
[Attachments]
Please provide the version information of each component, such as cdc/tikv, which can be obtained by executing cdc version/tikv-server --version.
Also, refer to this parameter tidb_super_read_only
.
If I set tidb_restricted_read_only to ON, will replication through the DM component still work normally?
I just tested it, and the incremental replication based on the DM component configuration reports an error, as follows:
mysql> show global variables like '%restricted%';
+---------------------------+-------+
| Variable_name | Value |
+---------------------------+-------+
| tidb_restricted_read_only | ON |
+---------------------------+-------+
1 row in set (0.00 sec)
mysql>
Starting component `dmctl`: /root/.tiup/components/dmctl/v6.1.0/dmctl/dmctl query-status --master-addr=x.x.x.x:8261
{
"result": true,
"msg": "",
"tasks": [
{
"taskName": "task_mysql1322033307_incremental",
"taskStatus": "Error - Some error occurred in subtask. Please run `query-status task_mysql1322033307_incremental` to get more details.",
"sources": [
"mysql1322033307"
]
}
]
}
By managing user permissions. Change all business accounts to read-only.
Huh? This doesn’t seem reasonable.
What is the specific error message from DM? Are you using the tidb root user?
Yes, I configured the root user for DM incremental replication.
I couldn’t find the parameter tidb_super_read_only
in the 6.1 documentation under system variables, but it appears in the TIDB show global variables
.
We introduced the TIDB_RESTRICTED_READ_ONLY
global variable. Turning it on will make the cluster read-only eventually for all users, including users with SUPER or CONNECTION_ADMIN privilege.
So, in TiDB’s read-only mode, how can we maintain continuous incremental replication with DM?
Try granting the RESTRICTED_REPLICA_WRITER_ADMIN
privilege to root.
The link above makes it very clear that the RESTRICTED_REPLICA_WRITER_ADMIN privilege is required.
- When the cluster is in read-only mode, no user (including the
SUPER
user) can execute SQL statements that might write data, unless the user is explicitly granted the RESTRICTED_REPLICA_WRITER_ADMIN
privilege.
Thank you, I didn’t read the documentation carefully. Adding the RESTRICTED_REPLICA_WRITER_ADMIN permission worked.
The design of RESTRICTED_REPLICA_WRITER_ADMIN
is quite special
Wouldn’t such a design cause many problems? After all, TiDB is not fully compatible with MySQL.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.