Config Manager

Listen all interface

Modify config file:/etc/clickhouse-server/config.xml

[root@liqiang.io]# cat /etc/clickhouse-server/config.xml
...
<listen_host>0.0.0.0</listen_host>
...

Change Storage Location

Modify config file:/etc/clickhouse-server/config.xml

[root@liqiang.io]#

User Manager

Create Admin User

Uncomment the access_management

[root@liqiang.io]# cat /etc/clickhouse-server/users.xml
..
<!-- User can create other users and grant rights to them. -->
<!-- <access_management>1</access_management> -->
..

Add normal user

[root@liqiang.io]# CREATE USER zhangsan IDENTIFIED WITH plaintext_password BY 'password' DEFAULT ROLE ALL;
[root@liqiang.io]#

Login with password

[root@liqiang.io]# clickhouse-client -h 127.0.0.1 --user zhangsan --ask-password

Grant permissions

  • execute with default user
[root@liqiang.io]# GRANT * ON prometheus TO zhangsan;

Database manager

Create database

[root@liqiang.io]# CREATE DATABASE IF NOT EXISTS prometheus;

Show database

[root@liqiang.io]# show DATABASES;

Change database

[root@liqiang.io]# use prometheus;

Table manager

Create Table

[root@liqiang.io]# CREATE TABLE time_series (\
    date Date,\
    fingerprint UInt64,\
    labels String\
)\
ENGINE = ReplacingMergeTree\
    PARTITION BY date\
    ORDER BY fingerprint;

CREATE TABLE samples (\
    fingerprint UInt64,\
    timestamp_ms Int64,\
    value Float64\
)\
ENGINE = MergeTree\
    PARTITION BY toDate(timestamp_ms / 1000)\
    ORDER BY (fingerprint, timestamp_ms);

View table

[root@liqiang.io]# show TABLES;

Ref