Search code examples
databaseclickhouse

Disable clickhouse logs in the system database


In clickhouse, there is a database called system where logs are stored.
My problem is that after installing clickhouse, the volume of the system database has increased a day, and I sent a photo of it, and if I only use it for 30 days, I have to allocate nearly 30 gigs of space on the server just for the system database, which costs It will be high.
Especially the two tables trace_log and part_log take a lot of space

enter image description here


How to disable the logs in the system database?

I have already seen the link below and did everything and it didn't work (link).

The following command does not work to prevent system database logs:

set log_queries = 0;

And also the following code does not work for me:

cat /etc/clickhouse-server/users.d/log_queries.xml
<?xml version="1.0" ?>
<yandex>
  <users>
    <default>
      <log_queries>0</log_queries>
    </default>
  </users>
</yandex>

I even went to this path sudo nano /etc/clickhouse-server/config.xml and I entered the following values, but it didn't work:

<logger>
    <level>none</level>
    <output>null</output>
</logger>

In addition, I restarted clickhouse every time to apply the changes

It is interesting here that when I do not insert any data into my database in my codes, the system database increases in size for no reason.
I searched a lot and did a lot of tests, but I didn't get any results. Thank you for your guidance


Solution

  • https://kb.altinity.com/altinity-kb-setup-and-maintenance/altinity-kb-system-tables-eat-my-disk/

    You can disable all / any of them

    Do not create log tables at all (a restart is needed for these changes to take effect).

    $ cat /etc/clickhouse-server/config.d/z_log_disable.xml
    <?xml version="1.0"?>
    <clickhouse>
        <asynchronous_metric_log remove="1"/>
        <metric_log remove="1"/>
        <query_thread_log remove="1" />  
        <query_log remove="1" />
        <query_views_log remove="1" />
        <part_log remove="1"/>
        <session_log remove="1"/>
        <text_log remove="1" />
        <trace_log remove="1"/>
        <crash_log remove="1"/>
        <opentelemetry_span_log remove="1"/>
        <zookeeper_log remove="1"/>
    </clickhouse>
    

    And you need to drop existing tables

    drop table system.trace_log;
    ...