配置管理
监听所有网卡
修改配置:/etc/clickhouse-server/config.xml
:
[[email protected]]# cat /etc/clickhouse-server/config.xml
...
<listen_host>0.0.0.0</listen_host>
...
存储位置
[[email protected]]#
用户管理
添加 Admin 用户
取消用户管理的注释:
[[email protected]]# cat /etc/clickhouse-server/users.xml
..
<!-- User can create other users and grant rights to them. -->
<!-- <access_management>1</access_management> -->
..
添加普通用户
[[email protected]]# CREATE USER zhangsan IDENTIFIED WITH plaintext_password BY 'password' DEFAULT ROLE ALL;
[[email protected]]#
用户带密码登录
[[email protected]]# clickhouse-client -h 127.0.0.1 --user zhangsan --ask-password
给用户权限
- 以 default 用户执行
[[email protected]]# GRANT * ON prometheus TO zhangsan;
数据库管理
创建数据库
[[email protected]]# CREATE DATABASE IF NOT EXISTS prometheus;
查看数据库
[[email protected]]# show DATABASES;
切换数据库
[[email protected]]# use prometheus;
表管理
创建表
[[email protected]]# 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);
查看表
[[email protected]]# show TABLES;