Enabling the Read-Only Mode for ClickHouse Tables
Scenarios
During operations such as data migration, one-click balancing, decommissioning, and scaling-in, it is essential to set the table to read-only mode to prevent unintended write operations. ClickHouse offers a table-level parameter only_allow_select_statement, which can be configured for MergeTree-series table engines. This parameter restricts operations such as ALTER, RENAME, DROP, and INSERT, allowing only SELECT operations to be executed.
Notes and Constraints
This section applies only to MRS 3.2.0-LTS or later.
Procedure for Enabling the Read-Only Mode of the ClickHouse Table
- Install the client. For details, see Installing a Client.
- Run the following commands to log in to the node where the client is installed as user root:
Navigate to the client installation directory.
cd Client installation directory
Configure environment variables.
source bigdata_env
- Run the following command to authenticate the user if the cluster is in security mode (with Kerberos authentication enabled). Otherwise, skip this step.
kinit Component service user
The user must have the ClickHouse administrator permissions.
- Run the proper client command to connect to the ClickHouse server.
- Normal mode
clickhouse client --host IP address of the ClickHouse instance --user Username --password --port 9440 --secure
Enter the user password.
- Security mode
clickhouse client --host IP address of the ClickHouse instance --port 9440 --secure
- MRS 3.2.0-LTS and earlier: For a cluster in normal mode, the default user is used. Alternatively, you can create an administrator using the open source capability provided by the ClickHouse community. Do not use the users created on FusionInsight Manager.
- MRS 3.3.0-LTS and later: For a cluster in normal mode, you can use the users created on FusionInsight Manager.
- To obtain the IP address of the ClickHouseServer instance, log in to FusionInsight Manager, choose Cluster > Services > ClickHouse, and click the Instances tab.
- Normal mode
- Run the following statement to set the table to read-only:
ALTER TABLE {table_name} MODIFY SETTING only_allow_select_statement = true;
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot