提交 ebf9d2a1 编写于 作者: V Vitaly Baranov

Added documentation for constraints on settings.

上级 4c7d71af
# Constraints on Settings
The constraints on settings can be defined in the `users` section of the `user.xml` configuration file and prohibit users from changing some of the settings with the `SET` query.
The constraints are defined as following:
```
<profiles>
<user_name>
<constraints>
<setting_name_1>
<min>lower_boundary</min>
</setting_name_1>
<setting_name_2>
<max>upper_boundary</max>
</setting_name_2>
<setting_name_3>
<min>lower_boundary</min>
<max>upper_boundary</max>
</setting_name_3>
<setting_name_4>
<readonly/>
</setting_name_4>
</constraints>
</user_name>
</profiles>
```
If user tries to violate the constraints an exception is thrown and the setting isn't actually changed.
There are supported three types of constraints: `min`, `max`, `readonly`. The `min` and `max` constraints specify upper and lower boundaries for a numeric setting and can be used in combination. The `readonly` constraint specify that the user cannot change the corresponding setting at all.
**Example:** Let `users.xml` includes lines:
```
<profiles>
<default>
<max_memory_usage>10000000000</max_memory_usage>
<force_index_by_date>0</force_index_by_date>
...
<constraints>
<max_memory_usage>
<min>5000000000</min>
<max>20000000000</max>
</max_memory_usage>
<force_index_by_date>
<readonly/>
</force_index_by_date>
</constraints>
</default>
</profiles>
```
The following queries all throw exceptions:
```
SET max_memory_usage=20000000001;
SET max_memory_usage=4999999999;
SET force_index_by_date=1;
```
```
Code: 452, e.displayText() = DB::Exception: Setting max_memory_usage should not be greater than 20000000000.
Code: 452, e.displayText() = DB::Exception: Setting max_memory_usage should not be less than 5000000000.
Code: 452, e.displayText() = DB::Exception: Setting force_index_by_date should not be changed.
```
**Note:** the `default` profile has a special handling: all the constraints defined for the `default` profile become the default constraints, so they restrict all the users until they're overriden explicitly for these users.
[Original article](https://clickhouse.yandex/docs/en/operations/settings/constraints_on_settings/) <!--hide-->
......@@ -31,6 +31,9 @@ After setting `readonly = 1`, the user can't change `readonly` and `allow_ddl` s
When using the `GET` method in the [HTTP interface](../../interfaces/http.md), `readonly = 1` is set automatically. To modify data, use the `POST` method.
Setting `readonly = 1` prohibit the user from changing all the settings. There is a way to prohibit the user
from changing only specific settings, for details see [constraints on settings](constraints_on_settings.md).
**Default value**
0
......
# Ограничения на изменение настроек
Ограничения на изменение настроек могут находиться внутри секции `users` файла `user.xml` и запрещают пользователю менять некоторые настройки с помощью запроса `SET`.
Выглядит это следующим образом:
```
<profiles>
<имя_пользователя>
<constraints>
<настройка_1>
<min>нижняя_граница</min>
</настройка_1>
<настройка_2>
<max>верхняя_граница</max>
</настройка_2>
<настройка_3>
<min>нижняя_граница</min>
<max>верхняя_граница</max>
</настройка_3>
<настройка_4>
<readonly/>
</настройка_4>
</constraints>
</имя_пользователя>
</profiles>
```
Если пользователь пытается выйти за пределы, установленные этими ограничениями, то кидается исключение и настройка сохраняет прежнее значение.
Поддерживаются три типа ограничений: `min`, `max` и `readonly`. Ограничения `min` и `max` указывают нижнюю и верхнюю границы для числовых настроек и могут использоваться вместе.
Ограничение `readonly` указывает, что пользователь не может менять настройку.
**Пример:** Пусть файл `users.xml` содержит строки:
```
<profiles>
<default>
<max_memory_usage>10000000000</max_memory_usage>
<force_index_by_date>0</force_index_by_date>
...
<constraints>
<max_memory_usage>
<min>5000000000</min>
<max>20000000000</max>
</max_memory_usage>
<force_index_by_date>
<readonly/>
</force_index_by_date>
</constraints>
</default>
</profiles>
```
Каждый из следующих запросов кинет исключение:
```
SET max_memory_usage=20000000001;
SET max_memory_usage=4999999999;
SET force_index_by_date=1;
```
```
Code: 452, e.displayText() = DB::Exception: Setting max_memory_usage should not be greater than 20000000000.
Code: 452, e.displayText() = DB::Exception: Setting max_memory_usage should not be less than 5000000000.
Code: 452, e.displayText() = DB::Exception: Setting force_index_by_date should not be changed.
```
**Примечание:** профиль с именем `default` обрабатывается специальным образом: все ограничения на изменение настроек из этого профиля становятся дефолтными и влияют на всех пользователей, кроме тех, где эти ограничения явно переопределены.
[Оригинальная статья](https://clickhouse.yandex/docs/ru/operations/settings/constraints_on_settings/) <!--hide-->
......@@ -27,10 +27,12 @@
- 1 — разрешены только запросы на чтение данных.
- 2 — разрешены запросы на чтение данных и изменение настроек.
После установки `readonly = 1`пользователь не может изменить настройки `readonly` и `allow_ddl` в текущей сессии.
После установки `readonly = 1` пользователь не может изменить настройки `readonly` и `allow_ddl` в текущей сессии.
При использовании метода `GET` в [HTTP интерфейсе](../../interfaces/http.md#http_interface), `readonly = 1` устанавливается автоматически. Для изменения данных используйте метод `POST`.
Установка `readonly = 1` запрещает изменение всех настроек. Существует способ запретить изменения только некоторых настроек, см. [ограничения на изменение настроек](constraints_on_settings.md).
**Значение по умолчанию**
0
......
......@@ -186,6 +186,7 @@ nav:
- 'Restrictions on Query Complexity': 'operations/settings/query_complexity.md'
- 'Settings': 'operations/settings/settings.md'
- 'Settings Profiles': 'operations/settings/settings_profiles.md'
- 'Constraints on Settings': 'operations/settings/constraints_on_settings.md'
- 'User Settings': 'operations/settings/settings_users.md'
- 'Utilities':
- 'Overview': 'operations/utils/index.md'
......
......@@ -185,6 +185,7 @@ nav:
- 'Разрешения на выполнение запросов': 'operations/settings/permissions_for_queries.md'
- 'Ограничения на сложность запроса': 'operations/settings/query_complexity.md'
- 'Настройки': 'operations/settings/settings.md'
- 'Ограничения на изменение настроек': 'operations/settings/constraints_on_settings.md'
- 'Профили настроек': 'operations/settings/settings_profiles.md'
- 'Утилиты':
- 'Введение': 'operations/utils/index.md'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册