【问题标题】:Not able to add settings 'log_queries=1' in clickhouse settings无法在 clickhouse 设置中添加设置“log_queries=1”
【发布时间】:2020-08-19 11:32:48
【问题描述】:

我想在我的 clickhouse 数据库中使用表 'system.query_log' 查看 query_logs。

但是当我触发 select 命令时,我收到错误,表不存在。然后我使用以下命令检查了设置:

Select * from system.settings where name = 'log_queries' LIMIT 1; 我收到以下回复:

Name         Value       changed         description        min      max         readonly       type

log_queries    0              0          Log request and    NULL     NULL          0            bool
                                         write to system
                                         tables

clickhouse 文档值列中的值应为“1”。 所以我尝试了更新命令,但失败并出现以下错误: “DB::Exception:存储系统设置不支持突变。”

如何更改此值并使日志记录成为可能,我应该在哪里进行这些更改?

【问题讨论】:

    标签: clickhouse


    【解决方案1】:

    要开启记录到system.query_log 需要在配置文件中设置log_queries

    1. /etc/clickhouse-server/users.d 文件夹中打开存在或创建新的自定义配置文件
    nano /etc/clickhouse-server/users.d/users.xml
    
    1. 设置所需参数
    <?xml version="1.0"?>
    <yandex>
        <profiles>
            <default>
                <log_queries replace="replace">1</log_queries>
            </default>
        </profiles>
    </yandex>
    

    【讨论】:

    • 谢谢弗拉基米尔。我可以在文件夹/etc/clickhouse-server 中看到一个名为 users.xml 的文件和一个文件夹 users.d,我应该更改这个文件还是在 users.d 中创建另一个文件?我还需要测试一些其他参数,例如“max_server_memory_usage_to_ram_ratio”,我应该直接在 config.xml 中进行更改,还是需要在 users.xml 中进行这些更改??我还需要在更改后重新启动服务器吗??
    • 任何具有自定义设置的文件应该位于 users.d 文件夹中 - 这很重要,因为位于那里的文件将 在 CH 升级时重写
    • 与存储自定义系统设置相同的规则 - 需要在文件夹 /etc/clickhouse-server/config.d 中创建配置文件
    • clickhouse-server-服务应该在更改系统设置时重新启动,而不是用户设置
    猜你喜欢
    • 2018-02-13
    • 2018-04-27
    • 2011-09-05
    • 2012-05-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多