Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set custom config? #2

Open
TheBuilderJR opened this issue Feb 24, 2022 · 6 comments
Open

How to set custom config? #2

TheBuilderJR opened this issue Feb 24, 2022 · 6 comments

Comments

@TheBuilderJR
Copy link

eg. what if I want to set max_memory_usage_for_user?

@TheBuilderJR
Copy link
Author

cc @anurag

@crcastle
Copy link

Hi @oslearningbear- There are a number of ways to configure that ClickHouse setting. You can do it by appending an argument to the Start Command like --max_memory_usage_for_user=value, using a users.xml configuration file, or a few other ways.

Check out https://clickhouse.com/docs/en/operations/settings/ for more details.

@TheBuilderJR
Copy link
Author

Thanks @crcastle. I don't understand how that works in the render paradigm. The start command for the template seems to be empty?
Screen Shot 2022-02-25 at 9 21 06 AM

@TheBuilderJR
Copy link
Author

I guess my question is how do I make changes to clickhouse config for this template running on render specifically.

@crcastle
Copy link

ClickHouse includes two default config files (config.xml and users.xml) but then allows you to override values in there or set ones that aren't defined in there.

Here's a way to do that on Render (and Docker generally):

  1. Click the green Use this template button for this repo. This will create a copy of the template in your personal or your team's GitHub org. Now we can customize things.
  2. Add a new file to the repo named custom_users.xml with the below as its contents. Values defined in this will override or add to values defined in /etc/clickhouse-server/users.xml, which is where default configuration values for users are defined.
    <?xml version="1.0"?>
    <clickhouse>
        <profiles>
            <default>
                <max_memory_usage_for_user>10000000</max_memory_usage_for_user>
            </default>
        </profiles>
    </clickhouse>
    The value max_memory_usage_for_users is in bytes -- making the above example approximately 10MB. I don't know if this is a useful value to use. It was just a test. Docs for this config value are here.
  3. Add a COPY line as below to the Dockerfile. This copies the custom config XML file to a place where ClickHouse expects to find config overrides.
    FROM yandex/clickhouse-server:21
    
    # Values in custom_users.xml will override values set in /etc/clickhouse-server/users.xml
    COPY custom_users.xml /etc/clickhouse-server/users.d/
  4. On the Render Dashboard, click New -> Blueprint and then search for and select your repo with these new or edited files.
  5. After the deploy is successful, you can verify ClickHouse set this configuration override using the clickhouse-client.
    1. Go to the Shell tab in the Render dashboard for this service.
    2. Then run clickhouse-client. You may need to append a --host parameter.
    3. Then run SELECT * from system.settings WHERE name='max_memory_usage_for_user';. The value in the value column should match what you set in the custom_users.xml file.

@TheBuilderJR
Copy link
Author

Thanks @crcastle! This is super useful. I wonder if it makes sense to also add this to the render/clickhouse docs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants